2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/statements/switchStatements/switchStatements.ts ===
|
|
|
|
module M {
|
2014-08-28 21:40:58 +02:00
|
|
|
>M : typeof M
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
export function fn(x: number) {
|
2014-08-28 21:52:44 +02:00
|
|
|
>fn : (x: number) => string
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : number
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var x: any;
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
switch (x) {
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
case '':
|
|
|
|
case 12:
|
|
|
|
case true:
|
|
|
|
case null:
|
|
|
|
case undefined:
|
|
|
|
>undefined : undefined
|
|
|
|
|
|
|
|
case new Date(12):
|
|
|
|
>new Date(12) : Date
|
2014-10-29 05:21:47 +01:00
|
|
|
>Date : DateConstructor
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
case new Object():
|
|
|
|
>new Object() : Object
|
2014-10-29 05:21:47 +01:00
|
|
|
>Object : ObjectConstructor
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
case /[a-z]/:
|
|
|
|
case[]:
|
|
|
|
>[] : undefined[]
|
|
|
|
|
|
|
|
case {}:
|
|
|
|
>{} : {}
|
|
|
|
|
|
|
|
case { id: 12 }:
|
|
|
|
>{ id: 12 } : { id: number; }
|
|
|
|
>id : number
|
|
|
|
|
|
|
|
case['a']:
|
|
|
|
>['a'] : string[]
|
|
|
|
|
|
|
|
case typeof x:
|
|
|
|
>typeof x : string
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
case typeof M:
|
|
|
|
>typeof M : string
|
|
|
|
>M : typeof M
|
|
|
|
|
|
|
|
case M.fn(1):
|
|
|
|
>M.fn(1) : string
|
2014-08-28 21:52:44 +02:00
|
|
|
>M.fn : (x: number) => string
|
2014-08-15 23:33:16 +02:00
|
|
|
>M : typeof M
|
2014-08-28 21:52:44 +02:00
|
|
|
>fn : (x: number) => string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
case <T>(x: number) => '':
|
|
|
|
><T>(x: number) => '' : <T>(x: number) => string
|
|
|
|
>T : T
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
case (<T>(x: number) => '')(2):
|
|
|
|
>(<T>(x: number) => '')(2) : string
|
|
|
|
>(<T>(x: number) => '') : <T>(x: number) => string
|
|
|
|
><T>(x: number) => '' : <T>(x: number) => string
|
|
|
|
>T : T
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
// basic assignable check, rest covered in tests for 'assignement compatibility'
|
|
|
|
class C { id: number; }
|
|
|
|
>C : C
|
|
|
|
>id : number
|
|
|
|
|
|
|
|
class D extends C { name: string }
|
|
|
|
>D : D
|
|
|
|
>C : C
|
|
|
|
>name : string
|
|
|
|
|
|
|
|
switch (new C()) {
|
|
|
|
>new C() : C
|
|
|
|
>C : typeof C
|
|
|
|
|
|
|
|
case new D():
|
|
|
|
>new D() : D
|
|
|
|
>D : typeof D
|
|
|
|
|
|
|
|
case { id: 12, name: '' }:
|
|
|
|
>{ id: 12, name: '' } : { id: number; name: string; }
|
|
|
|
>id : number
|
|
|
|
>name : string
|
|
|
|
|
|
|
|
case new C():
|
|
|
|
>new C() : C
|
|
|
|
>C : typeof C
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ('') { }
|
|
|
|
switch (12) { }
|
|
|
|
switch (true) { }
|
|
|
|
switch (null) { }
|
|
|
|
switch (undefined) { }
|
|
|
|
>undefined : undefined
|
|
|
|
|
|
|
|
switch (new Date(12)) { }
|
|
|
|
>new Date(12) : Date
|
2014-10-29 05:21:47 +01:00
|
|
|
>Date : DateConstructor
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
switch (new Object()) { }
|
|
|
|
>new Object() : Object
|
2014-10-29 05:21:47 +01:00
|
|
|
>Object : ObjectConstructor
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
switch (/[a-z]/) { }
|
|
|
|
switch ([]) { }
|
|
|
|
>[] : undefined[]
|
|
|
|
|
|
|
|
switch ({}) { }
|
|
|
|
>{} : {}
|
|
|
|
|
|
|
|
switch ({ id: 12 }) { }
|
|
|
|
>{ id: 12 } : { id: number; }
|
|
|
|
>id : number
|
|
|
|
|
|
|
|
switch (['a']) { }
|
|
|
|
>['a'] : string[]
|
|
|
|
|
|
|
|
switch (<T>(x: number) => '') { }
|
|
|
|
><T>(x: number) => '' : <T>(x: number) => string
|
|
|
|
>T : T
|
|
|
|
>x : number
|
|
|
|
|
|
|
|
switch ((<T>(x: T) => '')(1)) { }
|
|
|
|
>(<T>(x: T) => '')(1) : string
|
|
|
|
>(<T>(x: T) => '') : <T>(x: T) => string
|
|
|
|
><T>(x: T) => '' : <T>(x: T) => string
|
|
|
|
>T : T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
|
|
|
|
|