Skip to content

Commit

Permalink
String#matchAll should return iterable of RegExpExecArray (fixes #36788
Browse files Browse the repository at this point in the history
…) (#55565)

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
  • Loading branch information
nihil-admirari and sandersn committed Nov 30, 2023
1 parent 8d1fa44 commit fd74874
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/lib/es2020.string.d.ts
Expand Up @@ -6,7 +6,7 @@ interface String {
* containing the results of that search.
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
*/
matchAll(regexp: RegExp): IterableIterator<RegExpMatchArray>;
matchAll(regexp: RegExp): IterableIterator<RegExpExecArray>;

/** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */
toLocaleLowerCase(locales?: Intl.LocalesArgument): string;
Expand Down
20 changes: 10 additions & 10 deletions tests/baselines/reference/stringMatchAll.types
Expand Up @@ -2,23 +2,23 @@

=== stringMatchAll.ts ===
const matches = "matchAll".matchAll(/\w/g);
>matches : IterableIterator<RegExpMatchArray>
>"matchAll".matchAll(/\w/g) : IterableIterator<RegExpMatchArray>
>"matchAll".matchAll : (regexp: RegExp) => IterableIterator<RegExpMatchArray>
>matches : IterableIterator<RegExpExecArray>
>"matchAll".matchAll(/\w/g) : IterableIterator<RegExpExecArray>
>"matchAll".matchAll : (regexp: RegExp) => IterableIterator<RegExpExecArray>
>"matchAll" : "matchAll"
>matchAll : (regexp: RegExp) => IterableIterator<RegExpMatchArray>
>matchAll : (regexp: RegExp) => IterableIterator<RegExpExecArray>
>/\w/g : RegExp

const array = [...matches];
>array : RegExpMatchArray[]
>[...matches] : RegExpMatchArray[]
>...matches : RegExpMatchArray
>matches : IterableIterator<RegExpMatchArray>
>array : RegExpExecArray[]
>[...matches] : RegExpExecArray[]
>...matches : RegExpExecArray
>matches : IterableIterator<RegExpExecArray>

const { index, input } = array[0];
>index : number
>input : string
>array[0] : RegExpMatchArray
>array : RegExpMatchArray[]
>array[0] : RegExpExecArray
>array : RegExpExecArray[]
>0 : 0

0 comments on commit fd74874

Please sign in to comment.