Only check constraints in final phase of type inference#29647
Only check constraints in final phase of type inference#29647ahejlsberg merged 6 commits intomasterfrom
Conversation
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2554: Expected 2 arguments, but got 1. | ||
| !!! related TS6210 tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts:3:5: An argument for 'args' was not provided. No newline at end of file | ||
| !!! error TS2345: Argument of type '[]' is not assignable to parameter of type 'never'. No newline at end of file |
There was a problem hiding this comment.
So this swapped from an arity error to an assignability error because...? I would have assumed the arity error was preferable here. As written, there's no never or [], so I'm really not sure what I'd need to change to fix this error.
There was a problem hiding this comment.
The never comes from Parameters<T> when T isn't a function type. Neither error is particularly great, but the new error message is in some sense more correct. And, if you add a second argument in an attempt to fix the old error message, you're just greeted with the new error message.
There was a problem hiding this comment.
Ahh.... But a generator is a function type. You call it and get back an iterator, just like how you call an async function and get a promise. This error is straight wrong, then.
|
Latest commits switch to a simpler strategy. We now use a new |
|
The baseline change in |
This PR tweaks our inference logic to only check type parameter constraints in the final phase of type argument inference (and specifically not in the phase where contextually sensitive arguments are excluded). Checks prior to the final phase otherwise can cause inferences to become fixed when constraints are self-referential.
Fixes #29520.