New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when has optional elements in tuple types, Promise.all has error #28427

Open
jkchao opened this Issue Nov 9, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@jkchao

jkchao commented Nov 9, 2018

TypeScript Version: 3.1.3

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.

const arr: [Promise<number>, Promise<string>?] = [
  Promise.resolve(1)
];

arr[1] = Promise.resolve('1');

Promise.all(arr);    // Error

// or

const arr2: Array<Promise<number> | Promise<string>> = [Promise.resolve(1)];
arr2.push(Promise.resolve('1'));

Promise.all(arr2);   // Error

Expected behavior:

Promise.all(arr) should be correct

Actual behavior:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment