-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
🔎 Search Terms
61668 inference overload regression tuple
🕗 Version & Regression Information
- This changed in commit or PR Fix type variable leaks and cache inconsistencies #61668
⏯ Playground Link
💻 Code
declare function getNum(): Promise<number>;
declare function getStr(): Promise<string>;
declare function useTuple(tuple: [number, string]): void;
const p = Promise.resolve([]).then(() => Promise.all([getNum(), getStr()])).then(useTuple);
🙁 Actual behavior
The Promise.all
infers to Promise<(number|string)[]>
.
🙂 Expected behavior
The Promise.all
should infer Promise<[number, string]>
.
Additional information about the issue
This only happens when the Promise.all
call is directly returned. If I instead write
const p = Promise.all([getNum(), getStr()]);
return p;
then it infers the tuple correctly again, even without doing anything that would suggest it should infer the type differently.
This PR also impacted inference of enums: in another example, I pass {mode: new Subject(Mode.A)}
into a function that fails because it infers Subject<Mode.A>
while if I save a temporary const mode = new Subject(Mode.A);
then it infers Subject<Mode>
and passes.
jcrang and robpalme
Metadata
Metadata
Assignees
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases