-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Promise.all returns all values with type of the most common interface. #16017
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
Comments
Looks like the issue here is we have two definitions for The fix seems to reorder these overloads somehow to make sure the overloads from As a workaround, list the |
Thanks @mhegazy! I have applied your workaround and may confirm it works.
Still I find this But it is still not very clear what to specify there if I target the browser and want to have available all features polifilled by Is there somewhere better documentation about all of this? |
By default a matching version of the library is added to your compilation based on your target, so Sometimes you want to add definitions that are not part of the standard, for instance ones you have polyfiled, e.g. Library versions are cumulative, so if you set hope that helps. |
I'm wondering why this code doesn't compile unless I provide type arguments explicitly. function combine<T, U>(a: T, b: U): Promise<[T, U]> {
return Promise.all([a, b] as [T, U]);
} It compiles fine if I use |
@Andy-MS it is because we pick up overload I think the fix here is to remove Promise constructor definition from |
TypeScript Version: 2.3.3 / nightly (2.4.0-dev.20170523)
The problem can be reproduced with this code:
Expected behavior:
Compiles without errors
Actual behavior:
Compilation error:
I see that interface
B
is compatible with interfaceA
, but I don't think thatPromise.all
should return all values asA[]
.When you change interface
A
for example adding a fieldfieldA
, then interfaceB
is not compatible anymore and the code compiles without errors.I have created very small repository which reproduces this issue.
https://github.com/megaboich/ts-promise-all-issue
The text was updated successfully, but these errors were encountered: