Description
TypeScript Version: 3.7.0-beta
Search Terms:
promise all
Code
interface A {
a: string
}
interface B {
b: string
}
async function main(): Promise<A> {
const [a, b] = await Promise.all([
Promise.resolve({a: "a"} as A),
Promise.resolve({b: "b"} as B | undefined), // <- the `| undefined` here is the problem
]);
return a; // <- a has type `A | undefined`, but should be `A`
}
Expected behavior:
This is a regression from 3.6.3, where the return tuple of Promise.all
is correctly inferred.
Actual behavior:
A | undefined
bound of a different tuple member also adds a | undefined
bound on a different unrelated return value of Promise.all
.
Playground Link:
Related Issues:
Maybe #33707 ?