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
Promise.all and Promise.allSettled infer incorrect types from Array subclasses #51993
The inferred value should be of type number[] exactly like what happens with normal Array class. In the linked playground, It can be seen that Promise.all and Promise.allSettled infer the correct type with an Iterable type of object. This undesired behavior just happens with Array subclasses. I have quickly tried changing the signature from the original:
Yeah, we definitely can’t break tuple inference here. Seems like there could be another way to write it, but we’ll have to weigh the complexity and performance cost against how useful it actually is on average in real code.
Extending Array class, while uncommon is part of the language and this bug can be a wall against libraries development, for example. I'm going to spend some time in finding a solution as soon as I get the chance!
changed the title [-]Promise.all and Promise.allSettled infer incorrect types from Array child classes[/-][+]Promise.all and Promise.allSettled infer incorrect types from Array subclasses[/+]on Dec 22, 2022
Activity
IllusionMH commentedon Dec 22, 2022
This would break tuples, which (I assume), are more common use case than Array subclasses in promise methods.
Example
andrewbranch commentedon Dec 22, 2022
Yeah, we definitely can’t break tuple inference here. Seems like there could be another way to write it, but we’ll have to weigh the complexity and performance cost against how useful it actually is on average in real code.
asnaeb commentedon Dec 22, 2022
Extending Array class, while uncommon is part of the language and this bug can be a wall against libraries development, for example. I'm going to spend some time in finding a solution as soon as I get the chance!
[-]Promise.all and Promise.allSettled infer incorrect types from Array child classes[/-][+]Promise.all and Promise.allSettled infer incorrect types from Array subclasses[/+]asnaeb commentedon Dec 25, 2022
While I didn't test this exhaustively, It looks like it's working
Playground Link