Skip to content

Commit f42c791

Browse files
committed
Don't use es8. Add es2016 target.
Rename es7 to es2016. Update getDefaultLibFileName for new targets.
1 parent d16e846 commit f42c791

File tree

16 files changed

+69
-50
lines changed

16 files changed

+69
-50
lines changed

Jakefile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var compilerSources = [
7474
"transformers/module/system.ts",
7575
"transformers/module/module.ts",
7676
"transformers/jsx.ts",
77-
"transformers/es7.ts",
77+
"transformers/es2016.ts",
7878
"transformers/generators.ts",
7979
"transformers/es6.ts",
8080
"transformer.ts",
@@ -108,7 +108,7 @@ var servicesSources = [
108108
"transformers/module/system.ts",
109109
"transformers/module/module.ts",
110110
"transformers/jsx.ts",
111-
"transformers/es7.ts",
111+
"transformers/es2016.ts",
112112
"transformers/generators.ts",
113113
"transformers/es6.ts",
114114
"transformer.ts",

src/compiler/binder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,8 +2411,8 @@ namespace ts {
24112411
}
24122412
else if (operatorTokenKind === SyntaxKind.AsteriskAsteriskToken
24132413
|| operatorTokenKind === SyntaxKind.AsteriskAsteriskEqualsToken) {
2414-
// Exponentiation is ES7 syntax.
2415-
transformFlags |= TransformFlags.AssertES7;
2414+
// Exponentiation is ES2016 syntax.
2415+
transformFlags |= TransformFlags.AssertES2016;
24162416
}
24172417

24182418
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ namespace ts {
262262
"es3": ScriptTarget.ES3,
263263
"es5": ScriptTarget.ES5,
264264
"es6": ScriptTarget.ES6,
265-
"es8": ScriptTarget.ES8,
266265
"es2015": ScriptTarget.ES2015,
266+
"es2016": ScriptTarget.ES2016,
267267
"es2017": ScriptTarget.ES2017,
268268
}),
269269
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,

src/compiler/emitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,8 +2194,8 @@ const _super = (function (geti, seti) {
21942194

21952195
// Only emit __awaiter function when target ES5/ES6.
21962196
// Only emit __generator function when target ES5.
2197-
// For target ES8 and above, we can emit async/await as is.
2198-
if ((languageVersion < ScriptTarget.ES8) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) {
2197+
// For target ES2017 and above, we can emit async/await as is.
2198+
if ((languageVersion < ScriptTarget.ES2017) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) {
21992199
writeLines(awaiterHelper);
22002200
if (languageVersion < ScriptTarget.ES6) {
22012201
writeLines(generatorHelper);

src/compiler/transformer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="visitor.ts" />
22
/// <reference path="transformers/ts.ts" />
33
/// <reference path="transformers/jsx.ts" />
4-
/// <reference path="transformers/es7.ts" />
4+
/// <reference path="transformers/es2016.ts" />
55
/// <reference path="transformers/es6.ts" />
66
/// <reference path="transformers/generators.ts" />
77
/// <reference path="transformers/module/module.ts" />
@@ -115,8 +115,9 @@ namespace ts {
115115
transformers.push(transformJsx);
116116
}
117117

118-
if (languageVersion < ScriptTarget.ES8) {
119-
transformers.push(transformES7);
118+
119+
if (languageVersion < ScriptTarget.ES2016) {
120+
transformers.push(transformES2016);
120121
}
121122

122123
if (languageVersion < ScriptTarget.ES6) {

src/compiler/transformers/es7.ts renamed to src/compiler/transformers/es2016.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/*@internal*/
55
namespace ts {
6-
export function transformES7(context: TransformationContext) {
6+
export function transformES2016(context: TransformationContext) {
77
const { hoistVariableDeclaration } = context;
88

99
return transformSourceFile;
@@ -17,10 +17,10 @@ namespace ts {
1717
}
1818

1919
function visitor(node: Node): VisitResult<Node> {
20-
if (node.transformFlags & TransformFlags.ES7) {
20+
if (node.transformFlags & TransformFlags.ES2016) {
2121
return visitorWorker(node);
2222
}
23-
else if (node.transformFlags & TransformFlags.ContainsES7) {
23+
else if (node.transformFlags & TransformFlags.ContainsES2016) {
2424
return visitEachChild(node, visitor, context);
2525
}
2626
else {
@@ -40,7 +40,7 @@ namespace ts {
4040
}
4141

4242
function visitBinaryExpression(node: BinaryExpression): Expression {
43-
// We are here because ES7 adds support for the exponentiation operator.
43+
// We are here because ES2016 adds support for the exponentiation operator.
4444
const left = visitNode(node.left, visitor, isExpression);
4545
const right = visitNode(node.right, visitor, isExpression);
4646
if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskEqualsToken) {
@@ -98,4 +98,4 @@ namespace ts {
9898
}
9999
}
100100
}
101-
}
101+
}

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ namespace ts {
241241
return currentNamespace ? undefined : node;
242242

243243
case SyntaxKind.AsyncKeyword:
244-
// Async keyword is not elided for target ES8
245-
return languageVersion < ScriptTarget.ES8 ? undefined : node;
244+
return node;
246245

247246
case SyntaxKind.PublicKeyword:
248247
case SyntaxKind.PrivateKeyword:

src/compiler/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"visitor.ts",
2525
"transformers/ts.ts",
2626
"transformers/jsx.ts",
27-
"transformers/es7.ts",
27+
"transformers/es2016.ts",
2828
"transformers/es6.ts",
2929
"transformers/generators.ts",
3030
"transformers/destructuring.ts",

src/compiler/types.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,10 +2831,10 @@ namespace ts {
28312831
ES3 = 0,
28322832
ES5 = 1,
28332833
ES6 = 2,
2834-
ES8 = 3,
28352834
ES2015 = ES6,
2836-
ES2017 = ES8,
2837-
Latest = ES8,
2835+
ES2016 = 3,
2836+
ES2017 = 4,
2837+
Latest = ES2017,
28382838
}
28392839

28402840
export const enum LanguageVariant {
@@ -3119,44 +3119,47 @@ namespace ts {
31193119
ContainsTypeScript = 1 << 1,
31203120
Jsx = 1 << 2,
31213121
ContainsJsx = 1 << 3,
3122-
ES7 = 1 << 4,
3123-
ContainsES7 = 1 << 5,
3124-
ES6 = 1 << 6,
3125-
ContainsES6 = 1 << 7,
3126-
DestructuringAssignment = 1 << 8,
3127-
Generator = 1 << 9,
3128-
ContainsGenerator = 1 << 10,
3122+
ES2017 = 1 << 4,
3123+
ContainsES2017 = 1 << 5,
3124+
ES2016 = 1 << 6,
3125+
ContainsES2016 = 1 << 7,
3126+
ES6 = 1 << 8,
3127+
ContainsES6 = 1 << 9,
3128+
DestructuringAssignment = 1 << 10,
3129+
Generator = 1 << 11,
3130+
ContainsGenerator = 1 << 12,
31293131

31303132
// Markers
31313133
// - Flags used to indicate that a subtree contains a specific transformation.
3132-
ContainsDecorators = 1 << 11,
3133-
ContainsPropertyInitializer = 1 << 12,
3134-
ContainsLexicalThis = 1 << 13,
3135-
ContainsCapturedLexicalThis = 1 << 14,
3136-
ContainsLexicalThisInComputedPropertyName = 1 << 15,
3137-
ContainsDefaultValueAssignments = 1 << 16,
3138-
ContainsParameterPropertyAssignments = 1 << 17,
3139-
ContainsSpreadElementExpression = 1 << 18,
3140-
ContainsComputedPropertyName = 1 << 19,
3141-
ContainsBlockScopedBinding = 1 << 20,
3142-
ContainsBindingPattern = 1 << 21,
3143-
ContainsYield = 1 << 22,
3144-
ContainsHoistedDeclarationOrCompletion = 1 << 23,
3134+
ContainsDecorators = 1 << 13,
3135+
ContainsPropertyInitializer = 1 << 14,
3136+
ContainsLexicalThis = 1 << 15,
3137+
ContainsCapturedLexicalThis = 1 << 16,
3138+
ContainsLexicalThisInComputedPropertyName = 1 << 17,
3139+
ContainsDefaultValueAssignments = 1 << 18,
3140+
ContainsParameterPropertyAssignments = 1 << 19,
3141+
ContainsSpreadElementExpression = 1 << 20,
3142+
ContainsComputedPropertyName = 1 << 21,
3143+
ContainsBlockScopedBinding = 1 << 22,
3144+
ContainsBindingPattern = 1 << 23,
3145+
ContainsYield = 1 << 24,
3146+
ContainsHoistedDeclarationOrCompletion = 1 << 25,
31453147

31463148
HasComputedFlags = 1 << 29, // Transform flags have been computed.
31473149

31483150
// Assertions
31493151
// - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
31503152
AssertTypeScript = TypeScript | ContainsTypeScript,
31513153
AssertJsx = Jsx | ContainsJsx,
3152-
AssertES7 = ES7 | ContainsES7,
3154+
AssertES2017 = ES2017 | ContainsES2017,
3155+
AssertES2016 = ES2016 | ContainsES2016,
31533156
AssertES6 = ES6 | ContainsES6,
31543157
AssertGenerator = Generator | ContainsGenerator,
31553158

31563159
// Scope Exclusions
31573160
// - Bitmasks that exclude flags from propagating out of a specific context
31583161
// into the subtree flags of their container.
3159-
NodeExcludes = TypeScript | Jsx | ES7 | ES6 | DestructuringAssignment | Generator | HasComputedFlags,
3162+
NodeExcludes = TypeScript | Jsx | ES2017 | ES2016 | ES6 | DestructuringAssignment | Generator | HasComputedFlags,
31603163
ArrowFunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,
31613164
FunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsCapturedLexicalThis | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,
31623165
ConstructorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,

src/compiler/utilities.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4141,7 +4141,15 @@ namespace ts {
41414141

41424142
namespace ts {
41434143
export function getDefaultLibFileName(options: CompilerOptions): string {
4144-
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
4144+
switch (options.target) {
4145+
case ScriptTarget.ES2016:
4146+
return "lib.es2016.d.ts";
4147+
case ScriptTarget.ES6:
4148+
return "lib.es2015.d.ts";
4149+
4150+
default:
4151+
return "lib.d.ts";
4152+
}
41454153
}
41464154

41474155
export function textSpanEnd(span: TextSpan) {

0 commit comments

Comments
 (0)