From 7b1ca047d54ae28193f536079ee85a04804823ef Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 19 Sep 2016 17:06:44 -0700 Subject: [PATCH] Add regression test --- .../controlFlowWithIncompleteTypes.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/cases/compiler/controlFlowWithIncompleteTypes.ts 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