diff --git a/tests/cases/compiler/controlFlowWithIncompleteTypes.ts b/tests/cases/compiler/controlFlowWithIncompleteTypes.ts new file mode 100644 index 0000000000..a851e6652c --- /dev/null +++ b/tests/cases/compiler/controlFlowWithIncompleteTypes.ts @@ -0,0 +1,27 @@ +// Repro from #11000 + +declare var cond: boolean; + +function foo1() { + let x: string | number | boolean = 0; + while (cond) { + if (typeof x === "string") { + x = x.slice(); + } + else { + x = "abc"; + } + } +} + +function foo2() { + let x: string | number | boolean = 0; + while (cond) { + if (typeof x === "number") { + x = "abc"; + } + else { + x = x.slice(); + } + } +} \ No newline at end of file