-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Contextual typing based on instantiated types #30568
Conversation
@typescript-bot test this. |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at de76d55. You can monitor the build here. It should now contribute to this PR's status checks. |
@typescript-bot run dt |
Heya @ahejlsberg, I've started to run the Definitely Typed test suite on this PR at de76d55. You can monitor the build here. It should now contribute to this PR's status checks. |
The RWC tests are clean. The DT tests have a few changes that are to be expected: Now, when type inference produces no candidates and a type parameter has no explicit default, we consistently default to the constraint of the type parameter. Previously we'd default to |
The only example that doesn't work right now is the call to
Why does the call to |
We do some rudimentary signature filtering based on arity and since there is only one signature with arity two or greater we were able to produce a contextual signature for the |
* Update for microsoft/TypeScript#30568 * Use assignability instead of ExpectType Since assignability allows subtype relations
* Update for microsoft/TypeScript#30568 * Use assignability instead of ExpectType Since assignability allows subtype relations
New error from microsoft/TypeScript#30568 is correct.
With this PR we improve our ability to contextually type parameters of arrow functions and function expressions passed as arguments, allowing contextual types to depend on inferences made from other arguments. For example:
Above, the contextual type for each arrow function arguments depends on the type inferred for
K
from the first argument. Specifically, the contextual type for the arrow function argument is instantiated with inferences made from other arguments before the contextual type is applied to the arrow function parameters.Fixes #6611.
Fixes #21382.
Fixes #22149.
Fixes #25299.
Fixes #25759.
Fixes #25814.
Fixes #29775.
Fixes #30341.