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
{{ message }}
Repository navigation
when has optional elements in tuple types, Promise.all has error #28427
Search Terms:
Promise.all, optional elements in tuple types
Code
// A *self-contained* demonstration of the problem follows...// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.constarr: [Promise<number>,Promise<string>?]=[Promise.resolve(1)];arr[1]=Promise.resolve('1');Promise.all(arr);// Error// orconstarr2: Array<Promise<number>|Promise<string>>=[Promise.resolve(1)];arr2.push(Promise.resolve('1'));Promise.all(arr2);// Error
Activity
grassator commentedon Feb 15, 2019
The same (or similar) error happens when working with an array that can contain undefined items, which is OK according to the spec:
Since TS now has conditional types, I could imagine that the definition should be something like:
Better typings for Promise.all(), like microsoft#31117