-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Only check constraints in final phase of type inference #29647
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
Conversation
!!! error TS2345: Argument of type '[]' is not assignable to parameter of type 'never'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.