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