Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,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;
Expand Down
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