Please review this TypeScript code snippet (Version 3.8.3) on the playground:
interface TT { key: string };
let p1P: Promise<TT | void>;
let p2P: Promise<TT>;
(async () => {
const [p1, p2] = await Promise.all([p1P, p2P]);
// EXPECTED TYPES OF p1 and p2
// const p1: void | TT
// const p2: TT
// ACTUAL TYPES
// const p1: void | TT
// const p2: void | TT
});
Can you explain why the void
type is being added to the p2
variable after the await
keyword?