Skip to content

Commit 83f7f4d

Browse files
committed
Add regression test
1 parent 9844436 commit 83f7f4d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/cases/compiler/discriminantPropertyCheck.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,29 @@ const u: U = {} as any;
121121
u.a && u.b && f(u.a, u.b);
122122

123123
u.b && u.a && f(u.a, u.b);
124+
125+
// Repro from #29496
126+
127+
declare function never(value: never): never;
128+
129+
const enum BarEnum {
130+
bar1 = 1,
131+
bar2 = 2,
132+
}
133+
134+
type UnionOfBar = TypeBar1 | TypeBar2;
135+
type TypeBar1 = { type: BarEnum.bar1 };
136+
type TypeBar2 = { type: BarEnum.bar2 };
137+
138+
function func3(value: Partial<UnionOfBar>) {
139+
if (value.type !== undefined) {
140+
switch (value.type) {
141+
case BarEnum.bar1:
142+
break;
143+
case BarEnum.bar2:
144+
break;
145+
default:
146+
never(value.type);
147+
}
148+
}
149+
}

0 commit comments

Comments
 (0)