Skip to content

Commit d0be0cd

Browse files
String#matchAll should return iterable of RegExpExecArray (fixes #36788)
1 parent 7c417bf commit d0be0cd

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/lib/es2020.string.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ 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
}

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)