-
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
Infer between closely matching types in unions and intersections #32558
Conversation
@typescript-bot run dt |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 4c76bae. 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 parallelized Definitely Typed test suite on this PR at 00f41e5. You can monitor the build here. It should now contribute to this PR's status checks. |
DT tests look good. Only change is two new errors in |
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at a9e0a77. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at a9e0a77. You can monitor the build here. It should now contribute to this PR's status checks. |
DT tests still look good. There are minor changes in three projects in the RWC tests. I have reviewed all of them and they're fine. I think this PR is ready to merge. |
This PR further extends the work in #32460. The complete rules for union and intersection type inference are summarized in the following.
When inferring from a set of source types in a single type or a union of types to a set of target types in a union type:
When inferring from a set of source types in a single type or an intersection of types to a set of target types in an intersection type:
The rationale for eliminating identical types only when the target set of an intersection contains naked type variables is that when inferring from
string[] & { extra: any }
tostring[] & T
we want to removestring[]
and infer{ extra: any }
forT
, but when inferring tostring[] & Iterable<T>
we want to keep thestring[]
on the source side and inferstring
forT
.Fixes #32247.
Fixes #32572.