1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
//// [throwStatements.ts]
// all legal
interface I {
id: number;
}
class C implements I {
id: number;
}
class D<T>{
source: T;
recurse: D<T>;
wrapped: D<D<T>>
}
function F(x: string): number { return 42; }
module M {
export class A {
name: string;
}
export function F2(x: number): string { return x.toString(); }
}
var aNumber = 9.9;
throw aNumber;
var aString = 'this is a string';
throw aString;
var aDate = new Date(12);
throw aDate;
var anObject = new Object();
throw anObject;
var anAny = null;
throw anAny;
var anOtherAny = <any> new C();
throw anOtherAny;
var anUndefined = undefined;
throw anUndefined;
var aClass = new C();
throw aClass;
var aGenericClass = new D<string>();
throw aGenericClass;
var anObjectLiteral = { id: 12 };
throw anObjectLiteral;
var aFunction = F;
throw aFunction;
throw aFunction('');
var aLambda = (x) => 2;
throw aLambda;
throw aLambda(1);
var aModule = M;
throw aModule;
throw typeof M;
var aClassInModule = new M.A();
throw aClassInModule;
var aFunctionInModule = M.F2;
throw aFunctionInModule;
// no initializer or annotation, so this is an 'any'
var x;
throw x;
// literals
throw 0.0;
throw false;
throw null;
throw undefined;
throw 'a string';
throw function () { return 'a string' };
throw <T>(x:T) => 42;
throw { x: 12, y: 13 };
throw [];
throw ['a', ['b']];
throw /[a-z]/;
throw new Date();
throw new C();
throw new Object();
throw new D<number>();
//// [throwStatements.js]
// all legal
var C = /** @class */ (function () {
function C() {
}
return C;
}());
var D = /** @class */ (function () {
function D() {
}
return D;
}());
function F(x) { return 42; }
var M;
(function (M) {
var A = /** @class */ (function () {
function A() {
}
return A;
}());
M.A = A;
function F2(x) { return x.toString(); }
M.F2 = F2;
})(M || (M = {}));
var aNumber = 9.9;
throw aNumber;
var aString = 'this is a string';
throw aString;
var aDate = new Date(12);
throw aDate;
var anObject = new Object();
throw anObject;
var anAny = null;
throw anAny;
var anOtherAny = new C();
throw anOtherAny;
var anUndefined = undefined;
throw anUndefined;
var aClass = new C();
throw aClass;
var aGenericClass = new D();
throw aGenericClass;
var anObjectLiteral = { id: 12 };
throw anObjectLiteral;
var aFunction = F;
throw aFunction;
throw aFunction('');
var aLambda = function (x) { return 2; };
throw aLambda;
throw aLambda(1);
var aModule = M;
throw aModule;
throw typeof M;
var aClassInModule = new M.A();
throw aClassInModule;
var aFunctionInModule = M.F2;
throw aFunctionInModule;
// no initializer or annotation, so this is an 'any'
var x;
throw x;
// literals
throw 0.0;
throw false;
throw null;
throw undefined;
throw 'a string';
throw function () { return 'a string'; };
throw function (x) { return 42; };
throw { x: 12, y: 13 };
throw [];
throw ['a', ['b']];
throw /[a-z]/;
throw new Date();
throw new C();
throw new Object();
throw new D();
|