mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 10:00:13 -06:00
Add regression test
This commit is contained in:
parent
433ea84c52
commit
c6ca3f8114
24
tests/cases/compiler/controlFlowDestructuringLoop.ts
Normal file
24
tests/cases/compiler/controlFlowDestructuringLoop.ts
Normal file
@ -0,0 +1,24 @@
|
||||
// @strict: true
|
||||
|
||||
// Repro from #28758
|
||||
|
||||
interface NumVal { val: number; }
|
||||
interface StrVal { val: string; }
|
||||
type Val = NumVal | StrVal;
|
||||
|
||||
function isNumVal(x: Val): x is NumVal {
|
||||
return typeof x.val === 'number';
|
||||
}
|
||||
|
||||
function foo(things: Val[]): void {
|
||||
for (const thing of things) {
|
||||
if (isNumVal(thing)) {
|
||||
const { val } = thing;
|
||||
val.toFixed(2);
|
||||
}
|
||||
else {
|
||||
const { val } = thing;
|
||||
val.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user