mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Add tests
This commit is contained in:
@@ -12,4 +12,55 @@ function foo(x, y) {
|
||||
case 4:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare function noop(): void;
|
||||
declare function fail(): never;
|
||||
|
||||
function f1(x: 0 | 1 | 2) {
|
||||
switch (x) {
|
||||
case 0:
|
||||
fail();
|
||||
case 1:
|
||||
noop();
|
||||
case 2:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #34021
|
||||
|
||||
type Behavior = 'SLIDE' | 'SLIDE_OUT'
|
||||
type Direction = 'LEFT' | 'RIGHT' | 'TOP' | 'BOTTOM'
|
||||
|
||||
interface Transition {
|
||||
behavior: Behavior
|
||||
direction: Direction
|
||||
}
|
||||
|
||||
function f2(transition: Transition): any {
|
||||
switch (transition.behavior) {
|
||||
case 'SLIDE':
|
||||
switch (transition.direction) {
|
||||
case 'LEFT':
|
||||
return []
|
||||
case 'RIGHT':
|
||||
return []
|
||||
case 'TOP':
|
||||
return []
|
||||
case 'BOTTOM':
|
||||
return []
|
||||
}
|
||||
case 'SLIDE_OUT':
|
||||
switch (transition.direction) {
|
||||
case 'LEFT':
|
||||
return []
|
||||
case 'RIGHT':
|
||||
return []
|
||||
case 'TOP':
|
||||
return []
|
||||
case 'BOTTOM':
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user