Skip to content

Commit 45411e5

Browse files
committed
Add tests
1 parent 9479353 commit 45411e5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/cases/conformance/types/union/discriminatedUnionTypes2.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,25 @@ function f20<Data>(carrier: DataCarrier<Data>) {
7272
const data: null = carrier.data
7373
}
7474
}
75+
76+
// Repro from #28935
77+
78+
type Foo = { tag: true, x: number } | { tag: false, y: number } | { [x: string]: string };
79+
80+
function f30(foo: Foo) {
81+
if (foo.tag) {
82+
foo;
83+
}
84+
else {
85+
foo;
86+
}
87+
}
88+
89+
function f31(foo: Foo) {
90+
if (foo.tag === true) {
91+
foo;
92+
}
93+
else {
94+
foo;
95+
}
96+
}

0 commit comments

Comments
 (0)