- Notifications
You must be signed in to change notification settings - Fork13.2k
[Transforms] Down-level transformations for Async Functions#9175
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
rbuckton commentedJun 16, 2016
| } | ||
| exportfunctioncreateTempVariable(recordTempVariable:(node:Identifier)=>void,location?:TextRange):Identifier{ | ||
| exportfunctioncreateTempVariable(recordTempVariable:((node:Identifier)=>void)|undefined,location?:TextRange):Identifier{ |
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.
Why notrecordTempVariable?: (node: Identifier) => void?
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.
To catch mistakes. Its acceptable to not record the temp variable, but you almost always want to. The only cases where we don't are when we're creating a temp parameter, or we are going to add the temp variable name to aVariableDeclarationList ourselves.
weswigham commentedJun 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
We need to handle directive prologues ( Also, would it be possible to just see the results of those same conformance tests running vs es5/es3? I know you added a bunch of new tests, but simply replicating the |
weswigham commentedJun 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I don't think there's any issues, but I couldn't find a test to confirm - I don't see any tests (existing or otherwise) covering constructs such as |
| define(["require","exports"],function(require,exports){ | ||
| "use strict"; | ||
| return(_a={},_a["hi"]="there",_a); | ||
| return_a={},_a["hi"]="there",_a; |
weswighamJun 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Is the removal of the parenthesis in this test output and the one below intentional? #Resolved
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.
Yes. The node factories will automatically add parenthesis if they are needed. As a result, many places where we explicitly added parentheses now instead leverage this behavior. In this instance, thecreateReturn factory does not need to parenthesize, so they are not added.
…ity to treat some statements as if they were prologue directives.
…urning global promise, pass this to __generator
…referencing 'arguments' in a generator.
rbuckton commentedJun 28, 2016
@yuit,@weswigham: Please take another look following the recent commits. |
olee commentedJul 22, 2016
Does this PR being merged mean we can use async/await now with transpilation to < ES6? |
sandersn commentedJul 22, 2016
It's merged with the |
cime commentedSep 1, 2016
Anything new on this one? When will it be available in typescript@next? |
mhegazy commentedSep 1, 2016
should start showing up in |
nippur72 commentedSep 18, 2016
those using |
jkobylec commentedOct 14, 2016
I got excited enough by @mghegazy's comment earlier that I went ahead and installed typescript@next on my project to start refactoring some of my more labyrinthine promise usage into async/await. And did not bother to check whether And I was like, whoa, this already works when targeting ES5! But then I realized the output is still using ES6 generators, which just happen to work in Chrome and the iOS 10 webview I was testing in 🤐 |
mhegazy commentedOct 15, 2016
@jkobylec i do not think this is accurate. Emitting async functions for ES3/ES5 is supported in here is a demonstration. c:\test>tsc --vVersion 2.1.0-dev.20161014c:\test>type a.tsasync function test() { await bar();}c:\test>tsc --target ES5 --lib es5,es2015.promise a.tsa.ts(2,11): error TS2304: Cannotfind name 'bar'.c:\test>type a.jsvar __awaiter =...var __generator = ...function test() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, bar()]; case 1: _a.sent(); return [2 /*return*/]; } }); });} Also i would recommend creating a new issue instead of commenting on a closed PR. thanks. |
jkobylec commentedOct 15, 2016
My assumption was that the incorporation into master was still in progress
|
This change adds support for transforming a subset of generator function features to a down-level representation to support async functions when targeting ES5 or ES3.