-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Async Functions #1781
Async Functions #1781
Conversation
- fixed label fall-through - added implicit return - disallow 'with' in async - fixed ASI ambiguity with 'async' by disallowing newline - cleanup rewrite of ForInStatement
…t in some rewritten nodes
…nged how catch variables are renamed
…ating unique generated identifiers
…ve comments in rewrite
} | ||
|
||
function checkAwaitableReturnType(node: SignatureDeclaration, returnType: Type): Type { | ||
// an async function has a valid return type if the type has a construct signature that takes |
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.
When you say "the type has a construct signature...", you don't really mean the type. You mean the type resulting from resolving the name of that type as a value.
// - Explicit flags are set on contextFlags | ||
|
||
var previousContextFlags = contextFlags; | ||
contextFlags = (contextFlags & (ambientFlags | ~ParserContextFlags.ContextParameterFlags)) | explicitFlags; |
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.
I understand now. This is very ES6-y. I prefer the model where ambient flags are passed by just doing nothing, and flags are explicitly turned on and off. I know that what you've done here is more to the grammar, but for some reason I find it less intuitive.
Hello @rbuckton, I've tried to use your branch and found a compiler crash. Using this code:
gives this output:
I am using node 0.12.2 x64 on Windows 8.1 and the tsconfig.json is:
Hope this helps! |
closing this in favor of: #3078 |
@mhegazy does this mean async functions are only supported in ES6? Then why is that? |
@tinganho Downlevel support for async functions will likely end up in a separate PR. This one is extremely out of date. |
Ok thanks for explanation @rbuckton . I really want this feature in at least ES5 too. |
@teobugslayer perhaps it's related to #3978, with the difference that one is in the |
Changes Unknown when pulling d57fe72 on prototypeAsync into * on master*. |
Support for Async Functions, as per the proposal in #1664.
__awaiter
and__generator
helper functions to emit output (emitter.ts)