-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Promise.all sometimes infers incorrect types #52601
Comments
Possibly also related to #51993 |
We'd need some way to reproduce this |
no idea whether this is helpful or even related: in the past (probably 4.7.x or even 4.6.x) i had a vaguely similar problem without Promise.all involved at all, just some large-ish function call expression being awaited, and tsc complaining it could not assign to the variable because the types were mismatched. the interesting part was, that while
failed to compile,
worked perfectly fine, and at least in vscode the popup on xxx did show the expected type SomeType.
worked fine, too. to me the whole thing felt like the mechanism behind |
I think I found the issue. The problem is there are two overloads of https://github.com/microsoft/TypeScript/blob/main/lib/lib.es2015.iterable.d.ts#L227 The former is intended for arrays and the latter for tuples, but arrays are sometimes getting matched with the tuple overload. Moving the definitions into the same file and declaring the array one first solved my issue. (Per Typescript docs, TypeScript chooses the first matching overload, but I'm not sure what this behavior is if the overloads are specified in separate files. Probably it's undefined?) |
@RyanCavanaugh I've attached a repro to the issue. Hope you or someone else on the team could take a look. Thanks! |
Bug Report
π Search Terms
Promise.all, Awaited
π Version & Regression Information
4.9.5
β― Playground Link
I couldn't repro this bug in the playground.
Please see this test repo instead.
π» Code
Multiple files are needed to repro this bug. See the test repo. The relevant error is:
π Actual behavior
Code fails to build with:
This is because the return type of
Promise.all()
becomes aPromise<Array<Promise<Response>>>
instead of aPromise<Array<Response>>
.π Expected behavior
Code typechecks.
The text was updated successfully, but these errors were encountered: