It's complicated.
First of all, in this code
const p = new Promise((resolve) => { resolve(4); });
type p defined as Promise<{}> . There is an open problem about this on typescript github, so maybe this is a bug, because obviously (for humans) p should be Promise<number> .
Then Promise<{}> compatible with Promise<number> , because basically the only property that has a promise is the then method, and then compatible in these two types of promises according to the typescript function type compatibility rules . Therefore, there is no error in whatever1 .
But the goal of async is to pretend that you are dealing with actual values, not promises, and then you get an error in whatever2 because {} is obvioulsy incompatible with number .
So, the behavior of async is the same, but it currently needs some workaround to compile typescript. You can simply provide an explicit general argument when creating such a promise:
const whatever2 = async (): Promise<number> => { return new Promise<number>((resolve) => { resolve(4); }); };
artem source share