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
foo.ts(1,11): error TS1057: An async function or method must have a valid awaitable return type.
It's by design that the compiler may emit some output (which may be garbage) even if there's an error. If you don't want the compiler to emit on error then use noEmitOnError: true
Edit: And note that the error is somewhat misleading since the real reason is that async functions aren't supported when targeting ES5.
It's not specific to async arrow functions, it's when the async function is an expression (e.g. RHS of assignment) rather than a declaration.
@Arnavion that error TS1057 is due to an internal check that relies on the existence of Promise (which is not in ES5 by default). #7334 defines Promise, which unmasks the real problem - that no compiler errors are raised for async function expressions in ES5 even though the generated code is unusable.
TypeScript Version: Tested on 1.8.9 and Version 1.9.0-dev.20160327
Code
Compiles to the following (when
{"target": "es5"}
):The text was updated successfully, but these errors were encountered: