Add regression test

This commit is contained in:
Anders Hejlsberg
2016-07-04 20:38:00 -07:00
parent a8a8826f69
commit 829c3bc264
3 changed files with 44 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,8 @@
// Repro from #9507
function f(x: {a: "A", b} | {a: "C", e}) {
switch (x.a) {
case x:
break;
}
}