-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add ES2017 target #11407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ES2017 target #11407
Changes from 6 commits
2c46f9b
d16e846
f42c791
5d52c9f
1b4c0e3
e60e97f
f0fd77a
4284a74
7df3fda
c5ddf27
b871b53
a500fd9
86784a5
7352e97
17d60d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2411,8 +2411,8 @@ namespace ts { | |
} | ||
else if (operatorTokenKind === SyntaxKind.AsteriskAsteriskToken | ||
|| operatorTokenKind === SyntaxKind.AsteriskAsteriskEqualsToken) { | ||
// Exponentiation is ES7 syntax. | ||
transformFlags |= TransformFlags.AssertES7; | ||
// Exponentiation is ES2016 syntax. | ||
transformFlags |= TransformFlags.AssertES2016; | ||
} | ||
|
||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; | ||
|
@@ -2555,6 +2555,11 @@ namespace ts { | |
// extends clause of a class. | ||
let transformFlags = subtreeFlags | TransformFlags.AssertES6; | ||
|
||
// propagate ES2017 | ||
if (node.expression.transformFlags & TransformFlags.ContainsES2017) { | ||
transformFlags |= TransformFlags.ContainsES2017; | ||
} | ||
|
||
// If an ExpressionWithTypeArguments contains type arguments, then it | ||
// is TypeScript syntax. | ||
if (node.typeArguments) { | ||
|
@@ -2595,6 +2600,11 @@ namespace ts { | |
transformFlags |= TransformFlags.AssertTypeScript; | ||
} | ||
|
||
// Async MethodDeclaration is ES2017 | ||
if (modifierFlags & ModifierFlags.Async) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
transformFlags |= TransformFlags.AssertES2017; | ||
} | ||
|
||
// Currently, we only support generators that were originally async function bodies. | ||
if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { | ||
transformFlags |= TransformFlags.AssertGenerator; | ||
|
@@ -2656,7 +2666,7 @@ namespace ts { | |
|
||
// If a FunctionDeclaration is async, then it is TypeScript syntax. | ||
if (modifierFlags & ModifierFlags.Async) { | ||
transformFlags |= TransformFlags.AssertTypeScript; | ||
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this comment still accurate? Or are async functions valid ES2017 too? If so, they probably shouldn't be marked as typescript. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to this async/await is finished and will be part of es2017, so I believe you have a valid point there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
} | ||
|
||
// If a FunctionDeclaration's subtree has marked the container as needing to capture the | ||
|
@@ -2687,7 +2697,7 @@ namespace ts { | |
|
||
// An async function expression is TypeScript syntax. | ||
if (modifierFlags & ModifierFlags.Async) { | ||
transformFlags |= TransformFlags.AssertTypeScript; | ||
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as for async function declarations There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
} | ||
|
||
// If a FunctionExpression's subtree has marked the container as needing to capture the | ||
|
@@ -2717,7 +2727,7 @@ namespace ts { | |
|
||
// An async arrow function is TypeScript syntax. | ||
if (modifierFlags & ModifierFlags.Async) { | ||
transformFlags |= TransformFlags.AssertTypeScript; | ||
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; | ||
} | ||
|
||
// If an ArrowFunction contains a lexical this, its container must capture the lexical this. | ||
|
@@ -2856,14 +2866,18 @@ namespace ts { | |
let excludeFlags = TransformFlags.NodeExcludes; | ||
|
||
switch (kind) { | ||
case SyntaxKind.AsyncKeyword: | ||
case SyntaxKind.AwaitExpression: | ||
// Typescript async/await are ES2017 features | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as elsewhere. probably should just be AssertES2017 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; | ||
break; | ||
|
||
case SyntaxKind.PublicKeyword: | ||
case SyntaxKind.PrivateKeyword: | ||
case SyntaxKind.ProtectedKeyword: | ||
case SyntaxKind.AbstractKeyword: | ||
case SyntaxKind.DeclareKeyword: | ||
case SyntaxKind.AsyncKeyword: | ||
case SyntaxKind.ConstKeyword: | ||
case SyntaxKind.AwaitExpression: | ||
case SyntaxKind.EnumDeclaration: | ||
case SyntaxKind.EnumMember: | ||
case SyntaxKind.TypeAssertionExpression: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any
TransformFlags
of a subtree that should propagate should already be set insubtreeFlags
. There should be no need to explicitly propagate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done