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
  • Loading branch information
nihil-admirari committed Aug 29, 2023
1 parent 7c417bf commit d0be0cd
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ 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>;
}
20 changes: 10 additions & 10 deletions tests/baselines/reference/stringMatchAll.types
Original file line number Diff line number Diff line change
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 d0be0cd

Please sign in to comment.