- Notifications
You must be signed in to change notification settings - Fork 13.1k
Improve inference for signatures depending on types inferred from context-sensitive expressions #62725
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
base: main
Are you sure you want to change the base?
Improve inference for signatures depending on types inferred from context-sensitive expressions #62725
Conversation
| @typescript-bot test it |
| Hey @jakebailey, the results of running the DT tests are ready. There were interesting changes: Branch only errors:Package: carbon-components-react Package: d3-selection Package: d3-selection/v2 Package: d3-selection/v1 Package: react/v18 Package: react Package: jquery-jcrop Package: layui Package: oojs Package: pg Package: yaireo__tagify Package: jquery Package: meteor-mdg-validated-method Package: lodash Package: yargs |
| @jakebailey Here are the results of running the user tests with tsc comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Something interesting changed - please have a look. Details |
| @jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown Hosts
Scenarios
Developer Information: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @jakebailey Here are the results of running the top 400 repos with tsc comparing Something interesting changed - please have a look. Details |
| Repros:
|
The idea behind this PR is rather simple. Context-sensitive nodes are skipped by the first inference pass but that doesn't always mean they can't contain valid inference sources. Furthermore, using the constraints as inferred types after the first pass leads to signature applicability errors and thus skipping the second inference pass altogether (the one that starts including context-sensitive nodes).
So, whenever something potentially could be inferred into a type parameter from a context-sensitive node we can temporarily infer a wildcard to satisfy the signature applicability check with a more permissive candidate instantiation. Then the compiler can get to the second inference pass and potentially infer useful and concrete candidates.
This fixes a class of issues around inference in the presence of context-sensitive expressions when parts of the signature want to "process" the inferred type with conditional types and whatnot. Like here:
fixes #62204
fixes #55489
fixes #55124
fixes #54438
and fixes some of the issues reported in #47599