Infer between closely matching types in unions and intersections#32558
Infer between closely matching types in unions and intersections#32558ahejlsberg merged 10 commits intomasterfrom
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[] & Twe want to removestring[]and infer{ extra: any }forT, but when inferring tostring[] & Iterable<T>we want to keep thestring[]on the source side and inferstringforT.Fixes #32247.
Fixes #32572.