From 319ad71b159fe9bab4056dc65a9a67a9b25d0742 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 23 Dec 2017 19:28:13 -0800 Subject: [PATCH] Add regression test --- .../switchWithConstrainedTypeVariable.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/cases/conformance/controlFlow/switchWithConstrainedTypeVariable.ts diff --git a/tests/cases/conformance/controlFlow/switchWithConstrainedTypeVariable.ts b/tests/cases/conformance/controlFlow/switchWithConstrainedTypeVariable.ts new file mode 100644 index 00000000000..f6efd36811e --- /dev/null +++ b/tests/cases/conformance/controlFlow/switchWithConstrainedTypeVariable.ts @@ -0,0 +1,14 @@ +// @strict: true + +// Repro from #20840 + +function function1(key: T) { + switch (key) { + case 'a': + key.toLowerCase(); + break; + default: + key.toLowerCase(); + break; + } +}