Skip to content

Commit

Permalink
Return iterable of RegExpExecArray from RegExp#[Symbol.matchAll]
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel-rowe committed Nov 16, 2024
1 parent b3c67d3 commit 11944f3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/lib/es2020.symbol.wellknown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ interface RegExp {
* containing the results of that search.
* @param string A string to search within.
*/
[Symbol.matchAll](str: string): RegExpStringIterator<RegExpMatchArray>;
[Symbol.matchAll](str: string): RegExpStringIterator<RegExpExecArray>;
}
36 changes: 18 additions & 18 deletions tests/baselines/reference/regexMatchAll-esnext.types
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

=== regexMatchAll-esnext.ts ===
const matches = /\w/g[Symbol.matchAll]("matchAll");
>matches : RegExpStringIterator<RegExpMatchArray>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>/\w/g[Symbol.matchAll]("matchAll") : RegExpStringIterator<RegExpMatchArray>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>/\w/g[Symbol.matchAll] : (str: string) => RegExpStringIterator<RegExpMatchArray>
> : ^ ^^ ^^^^^
>matches : RegExpStringIterator<RegExpExecArray>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>/\w/g[Symbol.matchAll]("matchAll") : RegExpStringIterator<RegExpExecArray>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>/\w/g[Symbol.matchAll] : (str: string) => RegExpStringIterator<RegExpExecArray>
> : ^ ^^ ^^^^^
>/\w/g : RegExp
> : ^^^^^^
>Symbol.matchAll : unique symbol
Expand All @@ -20,24 +20,24 @@ const matches = /\w/g[Symbol.matchAll]("matchAll");
> : ^^^^^^^^^^

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

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

36 changes: 18 additions & 18 deletions tests/baselines/reference/regexMatchAll.types
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

=== regexMatchAll.ts ===
const matches = /\w/g[Symbol.matchAll]("matchAll");
>matches : RegExpStringIterator<RegExpMatchArray>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>/\w/g[Symbol.matchAll]("matchAll") : RegExpStringIterator<RegExpMatchArray>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>/\w/g[Symbol.matchAll] : (str: string) => RegExpStringIterator<RegExpMatchArray>
> : ^ ^^ ^^^^^
>matches : RegExpStringIterator<RegExpExecArray>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>/\w/g[Symbol.matchAll]("matchAll") : RegExpStringIterator<RegExpExecArray>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>/\w/g[Symbol.matchAll] : (str: string) => RegExpStringIterator<RegExpExecArray>
> : ^ ^^ ^^^^^
>/\w/g : RegExp
> : ^^^^^^
>Symbol.matchAll : unique symbol
Expand All @@ -20,24 +20,24 @@ const matches = /\w/g[Symbol.matchAll]("matchAll");
> : ^^^^^^^^^^

const array = [...matches];
>array : RegExpMatchArray[]
> : ^^^^^^^^^^^^^^^^^^
>[...matches] : RegExpMatchArray[]
> : ^^^^^^^^^^^^^^^^^^
>...matches : RegExpMatchArray
> : ^^^^^^^^^^^^^^^^
>matches : RegExpStringIterator<RegExpMatchArray>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>array : RegExpExecArray[]
> : ^^^^^^^^^^^^^^^^^
>[...matches] : RegExpExecArray[]
> : ^^^^^^^^^^^^^^^^^
>...matches : RegExpExecArray
> : ^^^^^^^^^^^^^^^
>matches : RegExpStringIterator<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 11944f3

Please sign in to comment.