You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks a lot for this refactoring, I think it's really useful and will push the adoption of async-await syntax 👍
This is a bug report related to this Twitter conversation: The converted code does not await for Promise.reject, thus the runtime does not throw but returns Promise.reject(3), which does not trigger the catch-clause but makes the function call return a rejected Promise.
I'm not 100% sure what the best conversion would be, but I assume it would be to always await for functions that could possibly return a Promise or expressions that are a Promise.
An async function always wraps the return value in a Promise. Using return await just adds extra time before the overreaching promise is resolved without changing the semantics.
First of all, thanks a lot for this refactoring, I think it's really useful and will push the adoption of async-await syntax 👍
This is a bug report related to this Twitter conversation: The converted code does not
await
forPromise.reject
, thus the runtime does not throw but returnsPromise.reject(3)
, which does not trigger thecatch
-clause but makes the function call return a rejected Promise.I'm not 100% sure what the best conversion would be, but I assume it would be to always await for functions that could possibly return a
Promise
or expressions that are aPromise
.TypeScript Version: Tested against https://github.com/Microsoft/TypeScript/tree/v3.1.1 and 4ed85b7
Failing testcases:
master
: https://github.com/rradczewski/TypeScript/tree/bug-return-needs-await (master...rradczewski:bug-return-needs-await)v3.1.1
: https://github.com/rradczewski/TypeScript/tree/bug-v3.1.1-return-needs-await (v3.1.1...rradczewski:bug-v3.1.1-return-needs-await)These assume that the correct behavior is to add
await
to a returned expression that yields a Promise.Search Terms:
Code
Running
testcase()
code will log2
and the returned Promise will resolve toundefined
.Expected behavior:
A call to
testcase()
would print2
and the returned Promise would resolve toundefined
as above.Actual behavior:
A call to
testcase()
this won't print2
but node will complain about an unhandled rejected promise.Related Issues:
await console.log(...)
await
toconsole.log
The text was updated successfully, but these errors were encountered: