Skip to content

Commit 290eff9

Browse files
committed
Add regression test
1 parent d25baf1 commit 290eff9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// @strict: true
2+
3+
// Repro from #28758
4+
5+
interface NumVal { val: number; }
6+
interface StrVal { val: string; }
7+
type Val = NumVal | StrVal;
8+
9+
function isNumVal(x: Val): x is NumVal {
10+
return typeof x.val === 'number';
11+
}
12+
13+
function foo(things: Val[]): void {
14+
for (const thing of things) {
15+
if (isNumVal(thing)) {
16+
const { val } = thing;
17+
val.toFixed(2);
18+
}
19+
else {
20+
const { val } = thing;
21+
val.length;
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)