Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace ts {
["es2017", "lib.es2017.d.ts"],
["es2018", "lib.es2018.d.ts"],
["es2019", "lib.es2019.d.ts"],
["es2020", "lib.es2020.d.ts"],
["esnext", "lib.esnext.d.ts"],
// Host only
["dom", "lib.dom.d.ts"],
Expand Down Expand Up @@ -46,6 +47,8 @@ namespace ts {
["es2019.array", "lib.es2019.array.d.ts"],
["es2019.string", "lib.es2019.string.d.ts"],
["es2019.symbol", "lib.es2019.symbol.d.ts"],
["es2020.string", "lib.es2020.string.d.ts"],
["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
["esnext.array", "lib.es2019.array.d.ts"],
["esnext.symbol", "lib.es2019.symbol.d.ts"],
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
Expand Down Expand Up @@ -210,6 +213,7 @@ namespace ts {
es2017: ScriptTarget.ES2017,
es2018: ScriptTarget.ES2018,
es2019: ScriptTarget.ES2019,
es2020: ScriptTarget.ES2020,
esnext: ScriptTarget.ESNext,
}),
affectsSourceFile: true,
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4747,7 +4747,8 @@ namespace ts {
ES2017 = 4,
ES2018 = 5,
ES2019 = 6,
ESNext = 7,
ES2020 = 7,
ESNext = 8,
JSON = 100,
Latest = ESNext,
}
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4673,6 +4673,8 @@ namespace ts {
switch (options.target) {
case ScriptTarget.ESNext:
return "lib.esnext.full.d.ts";
case ScriptTarget.ES2020:
return "lib.es2020.full.d.ts";
case ScriptTarget.ES2019:
return "lib.es2019.full.d.ts";
case ScriptTarget.ES2018:
Expand Down
3 changes: 3 additions & 0 deletions src/lib/es2020.d.ts
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" />
5 changes: 5 additions & 0 deletions src/lib/es2020.full.d.ts
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" />
10 changes: 10 additions & 0 deletions src/lib/es2020.string.d.ts
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>;
}
19 changes: 19 additions & 0 deletions src/lib/es2020.symbol.wellknown.d.ts
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>;
}
4 changes: 4 additions & 0 deletions src/lib/libs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"es2017",
"es2018",
"es2019",
"es2020",
"esnext",
// Host only
"dom.generated",
Expand Down Expand Up @@ -37,6 +38,8 @@
"es2019.array",
"es2019.string",
"es2019.symbol",
"es2020.string",
"es2020.symbol.wellknown",
"esnext.bigint",
"esnext.intl",
// Default libraries
Expand All @@ -46,6 +49,7 @@
"es2017.full",
"es2018.full",
"es2019.full",
"es2020.full",
"esnext.full"
],
"paths": {
Expand Down
3 changes: 3 additions & 0 deletions src/server/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3046,6 +3046,9 @@ namespace ts.server.protocol {
ES2015 = "ES2015",
ES2016 = "ES2016",
ES2017 = "ES2017",
ES2018 = "ES2018",
ES2019 = "ES2019",
ES2020 = "ES2020",
ESNext = "ESNext"
}
}
8 changes: 4 additions & 4 deletions src/testRunner/unittests/config/commandLineParsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace ts {
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
Expand Down Expand Up @@ -161,7 +161,7 @@ namespace ts {
start: undefined,
length: undefined,
}, {
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext'.",
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,

Expand Down Expand Up @@ -259,7 +259,7 @@ namespace ts {
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
Expand All @@ -278,7 +278,7 @@ namespace ts {
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
Expand Down
8 changes: 6 additions & 2 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2622,9 +2622,10 @@ declare namespace ts {
ES2017 = 4,
ES2018 = 5,
ES2019 = 6,
ESNext = 7,
ES2020 = 7,
ESNext = 8,
JSON = 100,
Latest = 7
Latest = 8
}
enum LanguageVariant {
Standard = 0,
Expand Down Expand Up @@ -8136,6 +8137,9 @@ declare namespace ts.server.protocol {
ES2015 = "ES2015",
ES2016 = "ES2016",
ES2017 = "ES2017",
ES2018 = "ES2018",
ES2019 = "ES2019",
ES2020 = "ES2020",
ESNext = "ESNext"
}
}
Expand Down
5 changes: 3 additions & 2 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2622,9 +2622,10 @@ declare namespace ts {
ES2017 = 4,
ES2018 = 5,
ES2019 = 6,
ESNext = 7,
ES2020 = 7,
ESNext = 8,
JSON = 100,
Latest = 7
Latest = 8
}
enum LanguageVariant {
Standard = 0,
Expand Down
10 changes: 10 additions & 0 deletions tests/baselines/reference/regexMatchAll.js
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];
16 changes: 16 additions & 0 deletions tests/baselines/reference/regexMatchAll.symbols
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))

24 changes: 24 additions & 0 deletions tests/baselines/reference/regexMatchAll.types
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

10 changes: 10 additions & 0 deletions tests/baselines/reference/stringMatchAll.js
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];
15 changes: 15 additions & 0 deletions tests/baselines/reference/stringMatchAll.symbols
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))

22 changes: 22 additions & 0 deletions tests/baselines/reference/stringMatchAll.types
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

5 changes: 5 additions & 0 deletions tests/cases/compiler/regexMatchAll.ts
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];
5 changes: 5 additions & 0 deletions tests/cases/compiler/stringMatchAll.ts
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];