String#matchAll should return iterable of RegExpExecArray (fixes #36788) (#55565)

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
Nil Admirari
2023-11-30 21:51:08 +00:00
committed by GitHub
parent 8d1fa440dd
commit fd74874733
2 changed files with 11 additions and 11 deletions

View File

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

View File

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