TypeScript/tests/baselines/reference/throwStatements.types

267 lines
4.2 KiB
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/conformance/statements/throwStatements/throwStatements.ts ===
// all legal
interface I {
>I : I
2014-08-15 23:33:16 +02:00
id: number;
>id : number
2014-08-15 23:33:16 +02:00
}
class C implements I {
>C : C
>I : I
2014-08-15 23:33:16 +02:00
id: number;
>id : number
2014-08-15 23:33:16 +02:00
}
class D<T>{
>D : D<T>
>T : T
2014-08-15 23:33:16 +02:00
source: T;
>source : T
>T : T
2014-08-15 23:33:16 +02:00
recurse: D<T>;
>recurse : D<T>
>D : D<T>
>T : T
2014-08-15 23:33:16 +02:00
wrapped: D<D<T>>
>wrapped : D<D<T>>
>D : D<T>
>D : D<T>
>T : T
2014-08-15 23:33:16 +02:00
}
function F(x: string): number { return 42; }
>F : (x: string) => number
>x : string
2015-04-13 21:36:11 +02:00
>42 : number
2014-08-15 23:33:16 +02:00
module M {
>M : typeof M
2014-08-15 23:33:16 +02:00
export class A {
>A : A
2014-08-15 23:33:16 +02:00
name: string;
>name : string
2014-08-15 23:33:16 +02:00
}
export function F2(x: number): string { return x.toString(); }
>F2 : (x: number) => string
>x : number
2014-08-15 23:33:16 +02:00
>x.toString() : string
>x.toString : (radix?: number) => string
>x : number
>toString : (radix?: number) => string
2014-08-15 23:33:16 +02:00
}
var aNumber = 9.9;
>aNumber : number
2015-04-13 21:36:11 +02:00
>9.9 : number
2014-08-15 23:33:16 +02:00
throw aNumber;
>aNumber : number
2014-08-15 23:33:16 +02:00
var aString = 'this is a string';
>aString : string
2015-04-13 21:36:11 +02:00
>'this is a string' : string
2014-08-15 23:33:16 +02:00
throw aString;
>aString : string
2014-08-15 23:33:16 +02:00
var aDate = new Date(12);
>aDate : Date
2014-08-15 23:33:16 +02:00
>new Date(12) : Date
>Date : DateConstructor
2015-04-13 21:36:11 +02:00
>12 : number
2014-08-15 23:33:16 +02:00
throw aDate;
>aDate : Date
2014-08-15 23:33:16 +02:00
var anObject = new Object();
>anObject : Object
2014-08-15 23:33:16 +02:00
>new Object() : Object
>Object : ObjectConstructor
2014-08-15 23:33:16 +02:00
throw anObject;
>anObject : Object
2014-08-15 23:33:16 +02:00
var anAny = null;
>anAny : any
2015-04-13 21:36:11 +02:00
>null : null
2014-08-15 23:33:16 +02:00
throw anAny;
>anAny : any
2014-08-15 23:33:16 +02:00
var anOtherAny = <any> new C();
>anOtherAny : any
2014-08-15 23:33:16 +02:00
><any> new C() : any
>new C() : C
>C : typeof C
2014-08-15 23:33:16 +02:00
throw anOtherAny;
>anOtherAny : any
2014-08-15 23:33:16 +02:00
var anUndefined = undefined;
>anUndefined : any
>undefined : undefined
2014-08-15 23:33:16 +02:00
throw anUndefined;
>anUndefined : any
2014-08-15 23:33:16 +02:00
var aClass = new C();
>aClass : C
2014-08-15 23:33:16 +02:00
>new C() : C
>C : typeof C
2014-08-15 23:33:16 +02:00
throw aClass;
>aClass : C
2014-08-15 23:33:16 +02:00
var aGenericClass = new D<string>();
>aGenericClass : D<string>
2014-08-15 23:33:16 +02:00
>new D<string>() : D<string>
>D : typeof D
2014-08-15 23:33:16 +02:00
throw aGenericClass;
>aGenericClass : D<string>
2014-08-15 23:33:16 +02:00
var anObjectLiteral = { id: 12 };
>anObjectLiteral : { id: number; }
2014-08-15 23:33:16 +02:00
>{ id: 12 } : { id: number; }
>id : number
2015-04-13 21:36:11 +02:00
>12 : number
2014-08-15 23:33:16 +02:00
throw anObjectLiteral;
>anObjectLiteral : { id: number; }
2014-08-15 23:33:16 +02:00
var aFunction = F;
>aFunction : (x: string) => number
>F : (x: string) => number
2014-08-15 23:33:16 +02:00
throw aFunction;
>aFunction : (x: string) => number
2014-08-15 23:33:16 +02:00
throw aFunction('');
>aFunction('') : number
>aFunction : (x: string) => number
2015-04-13 21:36:11 +02:00
>'' : string
2014-08-15 23:33:16 +02:00
var aLambda = (x) => 2;
>aLambda : (x: any) => number
2014-08-15 23:33:16 +02:00
>(x) => 2 : (x: any) => number
>x : any
2015-04-13 21:36:11 +02:00
>2 : number
2014-08-15 23:33:16 +02:00
throw aLambda;
>aLambda : (x: any) => number
2014-08-15 23:33:16 +02:00
throw aLambda(1);
>aLambda(1) : number
>aLambda : (x: any) => number
2015-04-13 21:36:11 +02:00
>1 : number
2014-08-15 23:33:16 +02:00
var aModule = M;
>aModule : typeof M
>M : typeof M
2014-08-15 23:33:16 +02:00
throw aModule;
>aModule : typeof M
2014-08-15 23:33:16 +02:00
throw typeof M;
>typeof M : string
>M : typeof M
2014-08-15 23:33:16 +02:00
var aClassInModule = new M.A();
>aClassInModule : M.A
2014-08-25 19:36:12 +02:00
>new M.A() : M.A
>M.A : typeof M.A
>M : typeof M
>A : typeof M.A
2014-08-15 23:33:16 +02:00
throw aClassInModule;
>aClassInModule : M.A
2014-08-15 23:33:16 +02:00
var aFunctionInModule = M.F2;
>aFunctionInModule : (x: number) => string
>M.F2 : (x: number) => string
>M : typeof M
>F2 : (x: number) => string
2014-08-15 23:33:16 +02:00
throw aFunctionInModule;
>aFunctionInModule : (x: number) => string
2014-08-15 23:33:16 +02:00
// no initializer or annotation, so this is an 'any'
var x;
>x : any
2014-08-15 23:33:16 +02:00
throw x;
>x : any
2014-08-15 23:33:16 +02:00
// literals
throw 0.0;
2015-04-13 21:36:11 +02:00
>0.0 : number
2014-08-15 23:33:16 +02:00
throw false;
2015-04-13 21:36:11 +02:00
>false : boolean
2014-08-15 23:33:16 +02:00
throw null;
2015-04-13 21:36:11 +02:00
>null : null
2014-08-15 23:33:16 +02:00
throw undefined;
>undefined : undefined
2014-08-15 23:33:16 +02:00
throw 'a string';
2015-04-13 21:36:11 +02:00
>'a string' : string
2014-08-15 23:33:16 +02:00
throw function () { return 'a string' };
>function () { return 'a string' } : () => string
2015-04-13 21:36:11 +02:00
>'a string' : string
2014-08-15 23:33:16 +02:00
throw <T>(x:T) => 42;
><T>(x:T) => 42 : <T>(x: T) => number
>T : T
>x : T
>T : T
2015-04-13 21:36:11 +02:00
>42 : number
2014-08-15 23:33:16 +02:00
throw { x: 12, y: 13 };
>{ x: 12, y: 13 } : { x: number; y: number; }
>x : number
2015-04-13 21:36:11 +02:00
>12 : number
>y : number
2015-04-13 21:36:11 +02:00
>13 : number
2014-08-15 23:33:16 +02:00
throw [];
>[] : undefined[]
throw ['a', ['b']];
>['a', ['b']] : (string | string[])[]
2015-04-13 21:36:11 +02:00
>'a' : string
2014-08-15 23:33:16 +02:00
>['b'] : string[]
2015-04-13 21:36:11 +02:00
>'b' : string
2014-08-15 23:33:16 +02:00
throw /[a-z]/;
2015-04-13 21:36:11 +02:00
>/[a-z]/ : RegExp
2014-08-15 23:33:16 +02:00
throw new Date();
>new Date() : Date
>Date : DateConstructor
2014-08-15 23:33:16 +02:00
throw new C();
>new C() : C
>C : typeof C
2014-08-15 23:33:16 +02:00
throw new Object();
>new Object() : Object
>Object : ObjectConstructor
2014-08-15 23:33:16 +02:00
throw new D<number>();
>new D<number>() : D<number>
>D : typeof D
2014-08-15 23:33:16 +02:00