Skip to content

Commit cc817bc

Browse files
committed
Add tests
1 parent a8b9f96 commit cc817bc

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

tests/cases/compiler/reachabilityChecks4.ts

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,55 @@ function foo(x, y) {
1212
case 4:
1313
return 3;
1414
}
15-
}
15+
}
16+
17+
declare function noop(): void;
18+
declare function fail(): never;
19+
20+
function f1(x: 0 | 1 | 2) {
21+
switch (x) {
22+
case 0:
23+
fail();
24+
case 1:
25+
noop();
26+
case 2:
27+
return;
28+
}
29+
}
30+
31+
// Repro from #34021
32+
33+
type Behavior = 'SLIDE' | 'SLIDE_OUT'
34+
type Direction = 'LEFT' | 'RIGHT' | 'TOP' | 'BOTTOM'
35+
36+
interface Transition {
37+
behavior: Behavior
38+
direction: Direction
39+
}
40+
41+
function f2(transition: Transition): any {
42+
switch (transition.behavior) {
43+
case 'SLIDE':
44+
switch (transition.direction) {
45+
case 'LEFT':
46+
return []
47+
case 'RIGHT':
48+
return []
49+
case 'TOP':
50+
return []
51+
case 'BOTTOM':
52+
return []
53+
}
54+
case 'SLIDE_OUT':
55+
switch (transition.direction) {
56+
case 'LEFT':
57+
return []
58+
case 'RIGHT':
59+
return []
60+
case 'TOP':
61+
return []
62+
case 'BOTTOM':
63+
return []
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)