Skip to content

Commit f7c4fef

Browse files
authored
Merge pull request #29167 from saschanaz/es2019
Add ES2019 target
2 parents f944ed6 + 343edb6 commit f7c4fef

48 files changed

Lines changed: 242 additions & 94 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3296,7 +3296,7 @@ namespace ts {
32963296
let transformFlags = subtreeFlags;
32973297

32983298
if (!node.variableDeclaration) {
3299-
transformFlags |= TransformFlags.AssertESNext;
3299+
transformFlags |= TransformFlags.AssertES2019;
33003300
}
33013301
else if (isBindingPattern(node.variableDeclaration.name)) {
33023302
transformFlags |= TransformFlags.AssertES2015;

src/compiler/commandLineParser.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace ts {
1515
["es2016", "lib.es2016.d.ts"],
1616
["es2017", "lib.es2017.d.ts"],
1717
["es2018", "lib.es2018.d.ts"],
18+
["es2019", "lib.es2019.d.ts"],
1819
["esnext", "lib.esnext.d.ts"],
1920
// Host only
2021
["dom", "lib.dom.d.ts"],
@@ -42,8 +43,11 @@ namespace ts {
4243
["es2018.intl", "lib.es2018.intl.d.ts"],
4344
["es2018.promise", "lib.es2018.promise.d.ts"],
4445
["es2018.regexp", "lib.es2018.regexp.d.ts"],
45-
["esnext.array", "lib.esnext.array.d.ts"],
46-
["esnext.symbol", "lib.esnext.symbol.d.ts"],
46+
["es2019.array", "lib.es2019.array.d.ts"],
47+
["es2019.string", "lib.es2019.string.d.ts"],
48+
["es2019.symbol", "lib.es2019.symbol.d.ts"],
49+
["esnext.array", "lib.es2019.array.d.ts"],
50+
["esnext.symbol", "lib.es2019.symbol.d.ts"],
4751
["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
4852
["esnext.intl", "lib.esnext.intl.d.ts"],
4953
["esnext.bigint", "lib.esnext.bigint.d.ts"]
@@ -198,14 +202,15 @@ namespace ts {
198202
es2016: ScriptTarget.ES2016,
199203
es2017: ScriptTarget.ES2017,
200204
es2018: ScriptTarget.ES2018,
205+
es2019: ScriptTarget.ES2019,
201206
esnext: ScriptTarget.ESNext,
202207
}),
203208
affectsSourceFile: true,
204209
affectsModuleResolution: true,
205210
paramType: Diagnostics.VERSION,
206211
showInSimplifiedHelpView: true,
207212
category: Diagnostics.Basic_Options,
208-
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_or_ESNEXT,
213+
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_or_ESNEXT,
209214
},
210215
{
211216
name: "module",

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3109,7 +3109,7 @@
31093109
"category": "Message",
31103110
"code": 6014
31113111
},
3112-
"Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'.": {
3112+
"Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'.": {
31133113
"category": "Message",
31143114
"code": 6015
31153115
},

src/compiler/transformer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ namespace ts {
4242
transformers.push(transformESNext);
4343
}
4444

45+
if (languageVersion < ScriptTarget.ES2019) {
46+
transformers.push(transformES2019);
47+
}
48+
4549
if (languageVersion < ScriptTarget.ES2018) {
4650
transformers.push(transformES2018);
4751
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*@internal*/
2+
namespace ts {
3+
export function transformES2019(context: TransformationContext) {
4+
return chainBundle(transformSourceFile);
5+
6+
function transformSourceFile(node: SourceFile) {
7+
if (node.isDeclarationFile) {
8+
return node;
9+
}
10+
11+
return visitEachChild(node, visitor, context);
12+
}
13+
14+
function visitor(node: Node): VisitResult<Node> {
15+
if ((node.transformFlags & TransformFlags.ContainsES2019) === 0) {
16+
return node;
17+
}
18+
switch (node.kind) {
19+
case SyntaxKind.CatchClause:
20+
return visitCatchClause(node as CatchClause);
21+
default:
22+
return visitEachChild(node, visitor, context);
23+
}
24+
}
25+
26+
function visitCatchClause(node: CatchClause): CatchClause {
27+
if (!node.variableDeclaration) {
28+
return updateCatchClause(
29+
node,
30+
createVariableDeclaration(createTempVariable(/*recordTempVariable*/ undefined)),
31+
visitNode(node.block, visitor, isBlock)
32+
);
33+
}
34+
return visitEachChild(node, visitor, context);
35+
}
36+
}
37+
}

src/compiler/transformers/esnext.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,9 @@ namespace ts {
1616
return node;
1717
}
1818
switch (node.kind) {
19-
case SyntaxKind.CatchClause:
20-
return visitCatchClause(node as CatchClause);
2119
default:
2220
return visitEachChild(node, visitor, context);
2321
}
2422
}
25-
26-
function visitCatchClause(node: CatchClause): CatchClause {
27-
if (!node.variableDeclaration) {
28-
return updateCatchClause(
29-
node,
30-
createVariableDeclaration(createTempVariable(/*recordTempVariable*/ undefined)),
31-
visitNode(node.block, visitor, isBlock)
32-
);
33-
}
34-
return visitEachChild(node, visitor, context);
35-
}
3623
}
3724
}

src/compiler/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"transformers/ts.ts",
3232
"transformers/es2017.ts",
3333
"transformers/es2018.ts",
34+
"transformers/es2019.ts",
3435
"transformers/esnext.ts",
3536
"transformers/jsx.ts",
3637
"transformers/es2016.ts",

src/compiler/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4658,7 +4658,8 @@ namespace ts {
46584658
ES2016 = 3,
46594659
ES2017 = 4,
46604660
ES2018 = 5,
4661-
ESNext = 6,
4661+
ES2019 = 6,
4662+
ESNext = 7,
46624663
JSON = 100,
46634664
Latest = ESNext,
46644665
}
@@ -5072,6 +5073,7 @@ namespace ts {
50725073
Super = 1 << 25,
50735074
ContainsSuper = 1 << 26,
50745075
ContainsES2018 = 1 << 27,
5076+
ContainsES2019 = 1 << 28,
50755077

50765078
// Please leave this as 1 << 29.
50775079
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
@@ -5083,6 +5085,7 @@ namespace ts {
50835085
AssertTypeScript = TypeScript | ContainsTypeScript,
50845086
AssertJsx = ContainsJsx,
50855087
AssertESNext = ContainsESNext,
5088+
AssertES2019 = ContainsES2019,
50865089
AssertES2018 = ContainsES2018,
50875090
AssertES2017 = ContainsES2017,
50885091
AssertES2016 = ContainsES2016,

src/compiler/utilities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4603,6 +4603,8 @@ namespace ts {
46034603
switch (options.target) {
46044604
case ScriptTarget.ESNext:
46054605
return "lib.esnext.full.d.ts";
4606+
case ScriptTarget.ES2019:
4607+
return "lib.es2019.full.d.ts";
46064608
case ScriptTarget.ES2018:
46074609
return "lib.es2018.full.d.ts";
46084610
case ScriptTarget.ES2017:

0 commit comments

Comments
 (0)