Description
Apologies if this has already been brought up, but I wasn't able to find any issues that cover this topic (#5911 seems closest).
The Current State
Currently, if you want to enforce typing of an async
function's resolved value, you must declare a return type of :Promise<ResolveType>
:
async function makeStuff():Promise<Stuff> {}
This is a bit counterintuitive when it comes to async
functions, as they generally mask the fact that there's a Promise
there to begin with. If you are utilizing promises purely via async
/await
, you're never going to see the token Promise
in your code.
Proposal
When providing the return type of an async
function, implicitly wrap it in a Promise<T>
(unless it is an explicit Promise<T>
type expression?). This seems reasonable now that #6631 is in.
async function makeStuff():Stuff {}
Seems like the least surprising way of declaring an async function