Open
Description
TypeScript Version: 3.1
Search Terms:
- async promise alias
- async promise conditional
Code
type P<T> = Promise<T>
async function foo<T>(x: T): P<T> {
return x;
}
async function bar<T>(x: T): T extends number ? Promise<number> : Promise<any> {
return x;
}
Expected behavior:
No error.
Actual behavior:
Type 'P' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
Type 'T extends number ? Promise : Promise' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
Playground Link:
Link
Related Issues: