Return iterable of RegExpExecArray from RegExp#[Symbol.matchAll] (#60516)

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
lionel-rowe
2026-02-06 22:21:51 +00:00
committed by GitHub
parent 0457b60701
commit 8bb72d2d96
3 changed files with 45 additions and 45 deletions

View File

@@ -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>;
}

View File

@@ -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
@@ -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 | undefined
> : ^^^^^^^^^^^^^^^^^^
>input : string | undefined
> : ^^^^^^^^^^^^^^^^^^
>array[0] : RegExpMatchArray
> : ^^^^^^^^^^^^^^^^
>array : RegExpMatchArray[]
> : ^^^^^^^^^^^^^^^^^^
>index : number
> : ^^^^^^
>input : string
> : ^^^^^^
>array[0] : RegExpExecArray
> : ^^^^^^^^^^^^^^^
>array : RegExpExecArray[]
> : ^^^^^^^^^^^^^^^^^
>0 : 0
> : ^

View File

@@ -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
@@ -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 | undefined
> : ^^^^^^^^^^^^^^^^^^
>input : string | undefined
> : ^^^^^^^^^^^^^^^^^^
>array[0] : RegExpMatchArray
> : ^^^^^^^^^^^^^^^^
>array : RegExpMatchArray[]
> : ^^^^^^^^^^^^^^^^^^
>index : number
> : ^^^^^^
>input : string
> : ^^^^^^
>array[0] : RegExpExecArray
> : ^^^^^^^^^^^^^^^
>array : RegExpExecArray[]
> : ^^^^^^^^^^^^^^^^^
>0 : 0
> : ^