Add tests

This commit is contained in:
Anders Hejlsberg
2019-10-13 09:45:56 -07:00
parent a8b9f964b6
commit cc817bc63e

View File

@@ -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 []
}
}
}