Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58898f4
commit 1a75d52
Showing
20 changed files
with
172 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference lib="es2019" /> | ||
/// <reference lib="es2020.string" /> | ||
/// <reference lib="es2020.symbol.wellknown" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference lib="es2020" /> | ||
/// <reference lib="dom" /> | ||
/// <reference lib="webworker.importscripts" /> | ||
/// <reference lib="scripthost" /> | ||
/// <reference lib="dom.iterable" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/// <reference lib="es2015.iterable" /> | ||
|
||
interface String { | ||
/** | ||
* Matches a string with a regular expression, and returns an iterable of matches | ||
* 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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// <reference lib="es2015.iterable" /> | ||
/// <reference lib="es2015.symbol" /> | ||
|
||
interface SymbolConstructor { | ||
/** | ||
* A regular expression method that matches the regular expression against a string. Called | ||
* by the String.prototype.matchAll method. | ||
*/ | ||
readonly matchAll: symbol; | ||
} | ||
|
||
interface RegExp { | ||
/** | ||
* Matches a string with this regular expression, and returns an iterable of matches | ||
* containing the results of that search. | ||
* @param string A string to search within. | ||
*/ | ||
[Symbol.matchAll](str: string): IterableIterator<RegExpMatchArray>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//// [regexMatchAll.ts] | ||
const matches = /\w/g[Symbol.matchAll]("matchAll"); | ||
const array = [...matches]; | ||
const { index, input } = array[0]; | ||
|
||
|
||
//// [regexMatchAll.js] | ||
const matches = /\w/g[Symbol.matchAll]("matchAll"); | ||
const array = [...matches]; | ||
const { index, input } = array[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
=== tests/cases/compiler/regexMatchAll.ts === | ||
const matches = /\w/g[Symbol.matchAll]("matchAll"); | ||
>matches : Symbol(matches, Decl(regexMatchAll.ts, 0, 5)) | ||
>Symbol.matchAll : Symbol(SymbolConstructor.matchAll, Decl(lib.es2020.symbol.wellknown.d.ts, --, --)) | ||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) | ||
>matchAll : Symbol(SymbolConstructor.matchAll, Decl(lib.es2020.symbol.wellknown.d.ts, --, --)) | ||
|
||
const array = [...matches]; | ||
>array : Symbol(array, Decl(regexMatchAll.ts, 1, 5)) | ||
>matches : Symbol(matches, Decl(regexMatchAll.ts, 0, 5)) | ||
|
||
const { index, input } = array[0]; | ||
>index : Symbol(index, Decl(regexMatchAll.ts, 2, 7)) | ||
>input : Symbol(input, Decl(regexMatchAll.ts, 2, 14)) | ||
>array : Symbol(array, Decl(regexMatchAll.ts, 1, 5)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
=== tests/cases/compiler/regexMatchAll.ts === | ||
const matches = /\w/g[Symbol.matchAll]("matchAll"); | ||
>matches : IterableIterator<RegExpMatchArray> | ||
>/\w/g[Symbol.matchAll]("matchAll") : IterableIterator<RegExpMatchArray> | ||
>/\w/g[Symbol.matchAll] : (str: string) => IterableIterator<RegExpMatchArray> | ||
>/\w/g : RegExp | ||
>Symbol.matchAll : symbol | ||
>Symbol : SymbolConstructor | ||
>matchAll : symbol | ||
>"matchAll" : "matchAll" | ||
|
||
const array = [...matches]; | ||
>array : RegExpMatchArray[] | ||
>[...matches] : RegExpMatchArray[] | ||
>...matches : RegExpMatchArray | ||
>matches : IterableIterator<RegExpMatchArray> | ||
|
||
const { index, input } = array[0]; | ||
>index : number | ||
>input : string | ||
>array[0] : RegExpMatchArray | ||
>array : RegExpMatchArray[] | ||
>0 : 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//// [stringMatchAll.ts] | ||
const matches = "matchAll".matchAll(/\w/g); | ||
const array = [...matches]; | ||
const { index, input } = array[0]; | ||
|
||
|
||
//// [stringMatchAll.js] | ||
const matches = "matchAll".matchAll(/\w/g); | ||
const array = [...matches]; | ||
const { index, input } = array[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
=== tests/cases/compiler/stringMatchAll.ts === | ||
const matches = "matchAll".matchAll(/\w/g); | ||
>matches : Symbol(matches, Decl(stringMatchAll.ts, 0, 5)) | ||
>"matchAll".matchAll : Symbol(String.matchAll, Decl(lib.es2020.string.d.ts, --, --)) | ||
>matchAll : Symbol(String.matchAll, Decl(lib.es2020.string.d.ts, --, --)) | ||
|
||
const array = [...matches]; | ||
>array : Symbol(array, Decl(stringMatchAll.ts, 1, 5)) | ||
>matches : Symbol(matches, Decl(stringMatchAll.ts, 0, 5)) | ||
|
||
const { index, input } = array[0]; | ||
>index : Symbol(index, Decl(stringMatchAll.ts, 2, 7)) | ||
>input : Symbol(input, Decl(stringMatchAll.ts, 2, 14)) | ||
>array : Symbol(array, Decl(stringMatchAll.ts, 1, 5)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
=== tests/cases/compiler/stringMatchAll.ts === | ||
const matches = "matchAll".matchAll(/\w/g); | ||
>matches : IterableIterator<RegExpMatchArray> | ||
>"matchAll".matchAll(/\w/g) : IterableIterator<RegExpMatchArray> | ||
>"matchAll".matchAll : (regexp: RegExp) => IterableIterator<RegExpMatchArray> | ||
>"matchAll" : "matchAll" | ||
>matchAll : (regexp: RegExp) => IterableIterator<RegExpMatchArray> | ||
>/\w/g : RegExp | ||
|
||
const array = [...matches]; | ||
>array : RegExpMatchArray[] | ||
>[...matches] : RegExpMatchArray[] | ||
>...matches : RegExpMatchArray | ||
>matches : IterableIterator<RegExpMatchArray> | ||
|
||
const { index, input } = array[0]; | ||
>index : number | ||
>input : string | ||
>array[0] : RegExpMatchArray | ||
>array : RegExpMatchArray[] | ||
>0 : 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// @target: es2020 | ||
|
||
const matches = /\w/g[Symbol.matchAll]("matchAll"); | ||
const array = [...matches]; | ||
const { index, input } = array[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// @target: es2020 | ||
|
||
const matches = "matchAll".matchAll(/\w/g); | ||
const array = [...matches]; | ||
const { index, input } = array[0]; |