Skip to content

Commit fd74874

Browse files
String#matchAll should return iterable of RegExpExecArray (fixes #36788) (#55565)
Co-authored-by: Nathan Shively-Sanders <[email protected]>
1 parent 8d1fa44 commit fd74874

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/lib/es2020.string.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface String {
66
* containing the results of that search.
77
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
88
*/
9-
matchAll(regexp: RegExp): IterableIterator<RegExpMatchArray>;
9+
matchAll(regexp: RegExp): IterableIterator<RegExpExecArray>;
1010

1111
/** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */
1212
toLocaleLowerCase(locales?: Intl.LocalesArgument): string;

tests/baselines/reference/stringMatchAll.types

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
=== stringMatchAll.ts ===
44
const matches = "matchAll".matchAll(/\w/g);
5-
>matches : IterableIterator<RegExpMatchArray>
6-
>"matchAll".matchAll(/\w/g) : IterableIterator<RegExpMatchArray>
7-
>"matchAll".matchAll : (regexp: RegExp) => IterableIterator<RegExpMatchArray>
5+
>matches : IterableIterator<RegExpExecArray>
6+
>"matchAll".matchAll(/\w/g) : IterableIterator<RegExpExecArray>
7+
>"matchAll".matchAll : (regexp: RegExp) => IterableIterator<RegExpExecArray>
88
>"matchAll" : "matchAll"
9-
>matchAll : (regexp: RegExp) => IterableIterator<RegExpMatchArray>
9+
>matchAll : (regexp: RegExp) => IterableIterator<RegExpExecArray>
1010
>/\w/g : RegExp
1111

1212
const array = [...matches];
13-
>array : RegExpMatchArray[]
14-
>[...matches] : RegExpMatchArray[]
15-
>...matches : RegExpMatchArray
16-
>matches : IterableIterator<RegExpMatchArray>
13+
>array : RegExpExecArray[]
14+
>[...matches] : RegExpExecArray[]
15+
>...matches : RegExpExecArray
16+
>matches : IterableIterator<RegExpExecArray>
1717

1818
const { index, input } = array[0];
1919
>index : number
2020
>input : string
21-
>array[0] : RegExpMatchArray
22-
>array : RegExpMatchArray[]
21+
>array[0] : RegExpExecArray
22+
>array : RegExpExecArray[]
2323
>0 : 0
2424

0 commit comments

Comments
 (0)