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
|
//// [nonPrimitiveAssignError.ts]
var x = {};
var y = {foo: "bar"};
var a: object;
x = a;
y = a; // expect error
a = x;
a = y;
var n = 123;
var b = true;
var s = "fooo";
a = n; // expect error
a = b; // expect error
a = s; // expect error
n = a; // expect error
b = a; // expect error
s = a; // expect error
var numObj: Number = 123;
var boolObj: Boolean = true;
var strObj: String = "string";
a = numObj; // ok
a = boolObj; // ok
a = strObj; // ok
//// [nonPrimitiveAssignError.js]
var x = {};
var y = { foo: "bar" };
var a;
x = a;
y = a; // expect error
a = x;
a = y;
var n = 123;
var b = true;
var s = "fooo";
a = n; // expect error
a = b; // expect error
a = s; // expect error
n = a; // expect error
b = a; // expect error
s = a; // expect error
var numObj = 123;
var boolObj = true;
var strObj = "string";
a = numObj; // ok
a = boolObj; // ok
a = strObj; // ok
|