Skip to content

Commit 829c3bc

Browse files
committed
Add regression test
1 parent a8a8826 commit 829c3bc

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
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"'.
2+
Type '{ a: "C"; e: any; }' is not comparable to type '"A" | "C"'.
3+
Type '{ a: "C"; e: any; }' is not comparable to type '"C"'.
4+
5+
6+
==== tests/cases/compiler/switchCaseCircularRefeference.ts (1 errors) ====
7+
// Repro from #9507
8+
9+
function f(x: {a: "A", b} | {a: "C", e}) {
10+
switch (x.a) {
11+
case x:
12+
~
13+
!!! error TS2678: Type '{ a: "A"; b: any; } | { a: "C"; e: any; }' is not comparable to type '"A" | "C"'.
14+
!!! error TS2678: Type '{ a: "C"; e: any; }' is not comparable to type '"A" | "C"'.
15+
!!! error TS2678: Type '{ a: "C"; e: any; }' is not comparable to type '"C"'.
16+
break;
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [switchCaseCircularRefeference.ts]
2+
// Repro from #9507
3+
4+
function f(x: {a: "A", b} | {a: "C", e}) {
5+
switch (x.a) {
6+
case x:
7+
break;
8+
}
9+
}
10+
11+
//// [switchCaseCircularRefeference.js]
12+
// Repro from #9507
13+
function f(x) {
14+
switch (x.a) {
15+
case x:
16+
break;
17+
}
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Repro from #9507
2+
3+
function f(x: {a: "A", b} | {a: "C", e}) {
4+
switch (x.a) {
5+
case x:
6+
break;
7+
}
8+
}

0 commit comments

Comments
 (0)