IssueRaiser

Nested Tagged Unions

**TypeScript Version:** 2.5.2 **Code** ```ts type A = { type: "a", a: number } type B = { type: "b", b: number } type X = { type: A, a: string } type Y = { type: B, b: string } let x: X | Y if (x.type.type === "a") { x.a // Type Error } ``` **Expected behavior:** I would expect x to have type `X` inside the if-statement after disambiguating the nested tagged union types. **Actual behavior:**

Posted by ccorcos on Sep 26, 2017, 1:17 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

github (Other)

Nested Tagged Unions

ccorcosSep 26, 2017, 1:17 AM

**TypeScript Version:** 2.5.2 **Code** ```ts type A = { type: "a", a: number } type B = { type: "b", b: number } type X = { type: A, a: string } type Y = { type: B, b: string } let x: X | Y if (x.type.type === "a") { x.a // Type Error } ``` **Expected behavior:** I would expect x to have type `X` inside the if-statement after disambiguating the nested tagged union types. **Actual behavior:**

Comments (0)

No comments yet. Start the discussion.

Comment on this issue