-
-
Notifications
You must be signed in to change notification settings - Fork 41
Unnecessary extra tick #47
Comments
Nice find, thanks for reporting. There is the edge case of what to do with functions thrown before an await statement to take into account. It's some time ago I looked it up in the spec, but I think the correct behaviour is to make these too reject the promise instead of returning an error. That would make the total code required be something like this instead:
Doing it that way would also keep the code generation easier since there wouldn't be two return styles to handle (resolve/reject calls vs. return/throw). |
@marten-de-vries it should reject the promise, and |
I hadn't really thought of these semantics before, but curious: should 1 log before 2 if you aren't awaiting foo();
console.log(2); versus: await foo();
console.log(2); Apologies if this seems obvious, but I wanted to verify behavior. |
Yes, the spec says that both examples should log 1 and then 2. |
should transpile to:
which should log 1, then 2.
but instead transpiles to:
This difference means the async function takes an extra tick - which results in logging 2, then 1.
The text was updated successfully, but these errors were encountered: