You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an effect of #18438. We now remove empty intersection types (i.e. intersection types for which no values exist) from union types. In your example, this means that undefined & (B & { c: C })[] is removed when constructing the type for bList, leaving just B[] & (B & { c: C })[]. Then, as we look for a map member on that type, we end up picking the candidate from B[] and therefore item has type B. Previously we'd pick a candidate from (B & { c: C })[] because we didn't remove the empty intersection.
In general, when the constituent types of intersections have overlapping signatures, the intersection is order sensitive because overload resolution processes the signatures from left to right. Indeed, your example works if you change the type of Q to list A last:
constQ: {bList: (B&{c: C})[]}&A={ ... };// Now works
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.6.1
Code
Expected behavior:
Until 2.5.1 this code did not generate a compilation error.
The type of bList is calculated as follows:
And type of item
Actual behavior:
With 2.6.x, this code causes an error.
The type of bList is calculated as follows:
And type of item
B
The type of item is treated as B and an error occurs. Is this change specified in the changelog?
The text was updated successfully, but these errors were encountered: