mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 02:45:24 -05:00
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:
2
src/lib/es2020.symbol.wellknown.d.ts
vendored
2
src/lib/es2020.symbol.wellknown.d.ts
vendored
@@ -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>;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
> : ^
|
||||
|
||||
|
||||
@@ -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
|
||||
> : ^
|
||||
|
||||
|
||||
Reference in New Issue
Block a user