Conversation
|
Hi @andrejbaran, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
src/compiler/commandLineParser.ts
Outdated
| "es3": ScriptTarget.ES3, | ||
| "es5": ScriptTarget.ES5, | ||
| "es6": ScriptTarget.ES6, | ||
| "es8": ScriptTarget.ES8, |
There was a problem hiding this comment.
Officially there is no ES8, it is ES2017, so i would not add ES8 here or anywhere else. i would just leave it to ES2017
src/compiler/commandLineParser.ts
Outdated
| "es3": ScriptTarget.ES3, | ||
| "es5": ScriptTarget.ES5, | ||
| "es6": ScriptTarget.ES6, | ||
| "es8": ScriptTarget.ES8, |
There was a problem hiding this comment.
Can you also add ES2016. it is a bit funny that we skip one ES 2016 (though not very useful but should be there for consistency).
src/compiler/commandLineParser.ts
Outdated
| "es3": ScriptTarget.ES3, | ||
| "es5": ScriptTarget.ES5, | ||
| "es6": ScriptTarget.ES6, | ||
| "es8": ScriptTarget.ES8, |
There was a problem hiding this comment.
you also need to update getDefaultLibFileName to inject the right library based on the target.
src/compiler/transformers/ts.ts
Outdated
| @@ -2453,14 +2464,28 @@ namespace ts { | |||
| * @param node The await expression node. | |||
| */ | |||
| function visitAwaitExpression(node: AwaitExpression): Expression { | |||
There was a problem hiding this comment.
async/await should be split into its own transform, es2017.ts, then we do not need to run it in this case, just like ES7 transform.
|
thanks @andrejbaran for the contribution. a few comments. also cc @rbuckton |
|
In theory trailing commas should also be preserved in the output for fidelity with |
yes, but the implementation today would make this a bit hard to achieve, not sure if there is much value though. |
Thinking about it more, at least one scenario comes to mind: ES feature detection. Not sure how useful that is in practice (NB the linked repo has 0 stars). Probably safe to ignore until someone raises an actual issue. |
|
Thanks for the review @mhegazy i'll get back to it tonight and will let you know |
Rename es7 to es2016. Update getDefaultLibFileName for new targets.
|
@mhegazy It turned out to be little more complicated than I anticipated, please review again. I have also renamed es7 to es2016 for consistency? (maybe es6 should be renamed too, dunno but I believe es2015 is preferred) |
src/compiler/binder.ts
Outdated
| // 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.
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.
According to this async/await is finished and will be part of es2017, so I believe you have a valid point there.
src/compiler/binder.ts
Outdated
| // 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.
same comment as for async function declarations
src/compiler/binder.ts
Outdated
| switch (kind) { | ||
| case SyntaxKind.AsyncKeyword: | ||
| case SyntaxKind.AwaitExpression: | ||
| // Typescript async/await are ES2017 features |
There was a problem hiding this comment.
same comment as elsewhere. probably should just be AssertES2017
| /// <reference path="../visitor.ts" /> | ||
|
|
||
| /*@internal*/ | ||
| namespace ts { |
There was a problem hiding this comment.
@rbuckton do you mind taking a look at least at this file and ts.ts?
src/compiler/transformers/ts.ts
Outdated
|
|
||
| case SyntaxKind.AwaitExpression: | ||
| // TypeScript 'await' expressions must be transformed. | ||
| // Typescript ES2017 async/await are handled by ES2017 transformer |
There was a problem hiding this comment.
I don't think you will even need this case if you mark async/await as ES2017 only
src/compiler/transformers/ts.ts
Outdated
| if (isAsyncFunctionLike(node)) { | ||
| return <FunctionBody>transformAsyncFunctionBody(node); | ||
| } | ||
| // if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { |
There was a problem hiding this comment.
delete this and the next comment section
src/compiler/binder.ts
Outdated
| // extends clause of a class. | ||
| let transformFlags = subtreeFlags | TransformFlags.AssertES6; | ||
|
|
||
| // propagate ES2017 |
There was a problem hiding this comment.
Any TransformFlags of a subtree that should propagate should already be set in subtreeFlags. There should be no need to explicitly propagate.
| } | ||
|
|
||
| // Async MethodDeclaration is ES2017 | ||
| if (modifierFlags & ModifierFlags.Async) { |
There was a problem hiding this comment.
Since async is ES2017, the test at line 2598 is now incorrect.
src/compiler/transformers/es2017.ts
Outdated
| return undefined; | ||
|
|
||
| case SyntaxKind.AwaitExpression: | ||
| // Typescript 'await' expressions must be transformed for targets < ES2017. |
There was a problem hiding this comment.
Should be ES2017 and not Typescript here
src/compiler/transformers/es2017.ts
Outdated
| return visitAwaitExpression(<AwaitExpression>node); | ||
|
|
||
| case SyntaxKind.MethodDeclaration: | ||
| // TypeScript method declarations may be 'async' |
There was a problem hiding this comment.
Should be ES2017 and not Typescript here
src/compiler/transformers/es2017.ts
Outdated
| return visitMethodDeclaration(<MethodDeclaration>node); | ||
|
|
||
| case SyntaxKind.FunctionDeclaration: | ||
| // TypeScript function declarations may be 'async' |
There was a problem hiding this comment.
Should be ES2017 and not Typescript here
src/compiler/types.ts
Outdated
| ContainsES2017 = 1 << 5, | ||
| ES2016 = 1 << 6, | ||
| ContainsES2016 = 1 << 7, | ||
| ES6 = 1 << 8, |
There was a problem hiding this comment.
Please change to ES2015 for consistency.
src/compiler/types.ts
Outdated
| ES2016 = 1 << 6, | ||
| ContainsES2016 = 1 << 7, | ||
| ES6 = 1 << 8, | ||
| ContainsES6 = 1 << 9, |
There was a problem hiding this comment.
Please change to ContainsES2015 for consistency.
src/compiler/types.ts
Outdated
| AssertES7 = ES7 | ContainsES7, | ||
| AssertES2017 = ES2017 | ContainsES2017, | ||
| AssertES2016 = ES2016 | ContainsES2016, | ||
| AssertES6 = ES6 | ContainsES6, |
There was a problem hiding this comment.
Please change to AssertES2015 for consistency.
src/compiler/utilities.ts
Outdated
| return "lib.es2017.d.ts"; | ||
| case ScriptTarget.ES2016: | ||
| return "lib.es2016.d.ts"; | ||
| case ScriptTarget.ES6: |
There was a problem hiding this comment.
Please use ES2015 here for consistency.
src/harness/harness.ts
Outdated
| return "lib.es2017.d.ts"; | ||
| case ts.ScriptTarget.ES2016: | ||
| return "lib.es2016.d.ts"; | ||
| case ts.ScriptTarget.ES6: |
There was a problem hiding this comment.
Please use ES2015 here for consistency.
|
@mhegazy @rbuckton @sandersn Review the changes pls. I also made the change from ES6 -> ES2015 through out the code so the naming scheme for ES versions is as consistent as possible. Let me know if that's not desired as I realise it's not the purpose of this PR, but since this PR kind of kicked off the consolidation I went for it. Again let me know if you're not ok with it (since it's quite a big change) |
src/compiler/types.ts
Outdated
| @@ -3055,7 +3055,9 @@ namespace ts { | |||
| ES5 = 1, | |||
| ES6 = 2, | |||
There was a problem hiding this comment.
this is minor, but can you make ES2015=2 and ES6=ES2015 ?
There was a problem hiding this comment.
Or maybe even delete ES6 if it's not used any more. I can't remember if this has anything to do with command line parsing, so it might be hard to tell.
There was a problem hiding this comment.
The only place where ES6 is used (other than comments) is in command line/compiler options parsing.
There was a problem hiding this comment.
removed ES6 completely
|
@rbuckton any comments? |
|
I concur with @sandersn that there are a number of unnecessarily duplicated tests. I need to go through them to see which ones are unneeded. Other than that, 👍 |
rbuckton
left a comment
There was a problem hiding this comment.
Most of the tests are fine as they also are vetting the emit for --target ES2017. I have marked some tests that are specific to either the checker or our down-level emit for ES6 that do not need to be duplicated.
I can approve this once those changes are made.
| await 0; | ||
| } | ||
|
|
||
| const asycnArrowFunc = async (): Promise<void> => { |
| @@ -0,0 +1,6 @@ | |||
| // @target: es2017 | |||
There was a problem hiding this comment.
This test is unnecessary as its only purpose is to verify return type check for async functions, which is already handled by the existing tests. The reason we differ between es5/es6 is that the rules governing whether this is allowed are different when targeting es5/3, but will be the same for es6+
| @@ -0,0 +1,4 @@ | |||
| // @target: es2017 | |||
There was a problem hiding this comment.
This test is unnecessary as its only purpose is to verify the checker with respect to async functions, which is already handled by existing tests.
| @@ -0,0 +1,6 @@ | |||
| // @target: es2017 | |||
There was a problem hiding this comment.
This test is unnecessary as its only purpose is to verify the checker with respect to async functions, which is already handled by existing tests.
| @@ -0,0 +1,3 @@ | |||
| // @target: es2017 | |||
There was a problem hiding this comment.
This test is unnecessary as its only purpose is to verify the checker with respect to async functions, which is already handled by existing tests.
| @@ -0,0 +1,5 @@ | |||
| // @target: es2017 | |||
There was a problem hiding this comment.
This test isn't really needed as it was added only to ensure the __awaiter helper was added to the correct file.
| @@ -0,0 +1,9 @@ | |||
| // @target: es2017 | |||
There was a problem hiding this comment.
This test is unnecessary as its only purpose is to verify the checker with respect to async functions, which is already handled by existing tests.
| @@ -0,0 +1,6 @@ | |||
| // @target: es2017 | |||
There was a problem hiding this comment.
This test is unnecessary as its only purpose is to verify the checker with respect to async functions, which is already handled by existing tests.
| @@ -0,0 +1,14 @@ | |||
| // @target: es2017 | |||
There was a problem hiding this comment.
This test is unnecessary as its only purpose is to verify the checker with respect to async functions, which is already handled by existing tests.
| @@ -0,0 +1,25 @@ | |||
| // @target: es2017 | |||
There was a problem hiding this comment.
This test is unnecessary as its only purpose is to verify the checker with respect to async functions, which is already handled by existing tests.
|
@rbuckton done. Thanks! |
|
thanks @andrejbaran! waiting on the travis, it has been 🐌 sloooow 🐌 today |
|
Travis CI looks to be running behind. Once the build passes I'll merge the pull request. Thanks @andrejbaran for the contribution! |
|
@andrejbaran My appologies, can you take a look at the merge conflict? |
|
@rbuckton should be ok now |
|
Many thanks guys! |
Hi there,
please consider this as a start for ES2017 target. Fixes #10768.
10/13/2016: This PR also includes a consolidation of naming of ES versions to reflect the official naming scheme (past es5) ES_YYYY_. This is a change through out the codebase.