You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript Version: 3.8.3 (regression - does not occur in 3.7)
Search Terms: Promise.all return type
Code
declareconstconditional: boolean;asyncfunctionfoo(): Promise<void>{// Note: promiseA cannot possibly resolve to undefinedconstpromiseA=Promise.resolve("hello");constpromiseB=conditional ? Promise.resolve(10) : Promise.resolve(undefined);const[resultA,resultB]=awaitPromise.all([promiseA,promiseB]);// Unexpected error here: resultA is possibly undefinedalert(resultA.toUpperCase());}```**Expected behavior:**Type of `resultA` should be `string`;**Actual behavior:**Type of `resultA` is `string|undefined`;**Workaround:**Tack on a `asconst` to the tuple of promises being passed to `Promise.all()`:```tsconst[resultA,resultB]=awaitPromise.all([promiseA,promiseB]asconst);