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
Thanks, @jack-williams, I figured someone must have run into this before but couldn't find it. This seems like an even simpler scenario, since here we would really only need the conclusion about y that we already deduce on the previous line to check that the assignment to v should be accepted, as opposed to using the nested discriminant to choose between different possible properties of the parent object c, the kind of thing desired in #18758.
TypeScript Version: 3.4.0-dev.20190305
Search Terms: nested discriminated union
Code
Expected behavior: The code compiles successfully.
Actual behavior: The assignment to
v
fails, with a message thatType 'C' is not assignable to type 'D'.
Playground Link: https://www.typescriptlang.org/play/#src=interface%20A%20%7B%0D%0A%20%20z%3A%20'a'%3B%0D%0A%7D%0D%0Ainterface%20B%20%7B%0D%0A%20%20z%3A%20'b'%3B%0D%0A%7D%0D%0Ainterface%20C%20%7B%0D%0A%20%20y%3A%20A%20%7C%20B%3B%0D%0A%7D%0D%0Ainterface%20D%20%7B%0D%0A%20%20y%3A%20A%3B%0D%0A%7D%0D%0Aconst%20x%20%3D%20(c%3A%20C)%20%3D%3E%20%7B%0D%0A%20%20if%20(c.y.z%20%3D%3D%3D%20'a')%20%7B%0D%0A%20%20%20%20const%20w%3A%20A%20%3D%20c.y%3B%0D%0A%20%20%20%20const%20v%3A%20D%20%3D%20c%3B%0D%0A%20%20%7D%0D%0A%7D%3B%0D%0A
The text was updated successfully, but these errors were encountered: