From 829c3bc2649a920ce68f87f240708b74abbe97c5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 4 Jul 2016 20:38:00 -0700 Subject: [PATCH] Add regression test --- .../switchCaseCircularRefeference.errors.txt | 18 ++++++++++++++++++ .../reference/switchCaseCircularRefeference.js | 18 ++++++++++++++++++ .../compiler/switchCaseCircularRefeference.ts | 8 ++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/baselines/reference/switchCaseCircularRefeference.errors.txt create mode 100644 tests/baselines/reference/switchCaseCircularRefeference.js create mode 100644 tests/cases/compiler/switchCaseCircularRefeference.ts diff --git a/tests/baselines/reference/switchCaseCircularRefeference.errors.txt b/tests/baselines/reference/switchCaseCircularRefeference.errors.txt new file mode 100644 index 00000000000..9ee571de468 --- /dev/null +++ b/tests/baselines/reference/switchCaseCircularRefeference.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/switchCaseCircularRefeference.ts(5,10): error TS2678: Type '{ a: "A"; b: any; } | { a: "C"; e: any; }' is not comparable to type '"A" | "C"'. + Type '{ a: "C"; e: any; }' is not comparable to type '"A" | "C"'. + Type '{ a: "C"; e: any; }' is not comparable to type '"C"'. + + +==== tests/cases/compiler/switchCaseCircularRefeference.ts (1 errors) ==== + // Repro from #9507 + + function f(x: {a: "A", b} | {a: "C", e}) { + switch (x.a) { + case x: + ~ +!!! error TS2678: Type '{ a: "A"; b: any; } | { a: "C"; e: any; }' is not comparable to type '"A" | "C"'. +!!! error TS2678: Type '{ a: "C"; e: any; }' is not comparable to type '"A" | "C"'. +!!! error TS2678: Type '{ a: "C"; e: any; }' is not comparable to type '"C"'. + break; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/switchCaseCircularRefeference.js b/tests/baselines/reference/switchCaseCircularRefeference.js new file mode 100644 index 00000000000..7ef901511cf --- /dev/null +++ b/tests/baselines/reference/switchCaseCircularRefeference.js @@ -0,0 +1,18 @@ +//// [switchCaseCircularRefeference.ts] +// Repro from #9507 + +function f(x: {a: "A", b} | {a: "C", e}) { + switch (x.a) { + case x: + break; + } +} + +//// [switchCaseCircularRefeference.js] +// Repro from #9507 +function f(x) { + switch (x.a) { + case x: + break; + } +} diff --git a/tests/cases/compiler/switchCaseCircularRefeference.ts b/tests/cases/compiler/switchCaseCircularRefeference.ts new file mode 100644 index 00000000000..060b90fa8a1 --- /dev/null +++ b/tests/cases/compiler/switchCaseCircularRefeference.ts @@ -0,0 +1,8 @@ +// Repro from #9507 + +function f(x: {a: "A", b} | {a: "C", e}) { + switch (x.a) { + case x: + break; + } +} \ No newline at end of file