2014-07-13 01:04:16 +02:00
|
|
|
//// [plusOperatorWithAnyOtherType.ts]
|
|
|
|
// + operator on any type
|
|
|
|
|
|
|
|
var ANY: any;
|
|
|
|
var ANY1;
|
|
|
|
var ANY2: any[] = ["", ""];
|
|
|
|
var obj: () => {}
|
|
|
|
var obj1 = { x: (s: string) => { }, y: (s1) => { }};
|
|
|
|
|
|
|
|
function foo(): any {
|
|
|
|
var a;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
class A {
|
|
|
|
public a: any;
|
|
|
|
static foo() {
|
|
|
|
var a;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module M {
|
|
|
|
export var n: any;
|
|
|
|
}
|
|
|
|
var objA = new A();
|
|
|
|
|
|
|
|
// any other type var
|
|
|
|
var ResultIsNumber1 = +ANY1;
|
|
|
|
var ResultIsNumber2 = +ANY2;
|
|
|
|
var ResultIsNumber3 = +A;
|
|
|
|
var ResultIsNumber4 = +M;
|
|
|
|
var ResultIsNumber5 = +obj;
|
|
|
|
var ResultIsNumber6 = +obj1;
|
|
|
|
|
|
|
|
// any type literal
|
|
|
|
var ResultIsNumber7 = +undefined;
|
|
|
|
var ResultIsNumber8 = +null;
|
|
|
|
|
|
|
|
// any type expressions
|
|
|
|
var ResultIsNumber9 = +ANY2[0];
|
|
|
|
var ResultIsNumber10 = +obj1.x;
|
|
|
|
var ResultIsNumber11 = +obj1.y;
|
|
|
|
var ResultIsNumber12 = +objA.a;
|
|
|
|
var ResultIsNumber13 = +M.n;
|
|
|
|
var ResultIsNumber14 = +foo();
|
|
|
|
var ResultIsNumber15 = +A.foo();
|
|
|
|
var ResultIsNumber16 = +(ANY + ANY1);
|
|
|
|
var ResultIsNumber17 = +(null + undefined);
|
|
|
|
var ResultIsNumber18 = +(null + null);
|
|
|
|
var ResultIsNumber19 = +(undefined + undefined);
|
|
|
|
|
|
|
|
// miss assignment operators
|
|
|
|
+ANY;
|
|
|
|
+ANY1;
|
|
|
|
+ANY2[0];
|
|
|
|
+ANY, ANY1;
|
|
|
|
+objA.a;
|
|
|
|
+M.n;
|
|
|
|
|
|
|
|
//// [plusOperatorWithAnyOtherType.js]
|
2014-08-12 00:54:12 +02:00
|
|
|
// + operator on any type
|
2014-07-13 01:04:16 +02:00
|
|
|
var ANY;
|
|
|
|
var ANY1;
|
|
|
|
var ANY2 = ["", ""];
|
|
|
|
var obj;
|
|
|
|
var obj1 = { x: function (s) {
|
|
|
|
}, y: function (s1) {
|
|
|
|
} };
|
|
|
|
function foo() {
|
|
|
|
var a;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
var A = (function () {
|
|
|
|
function A() {
|
|
|
|
}
|
|
|
|
A.foo = function () {
|
|
|
|
var a;
|
|
|
|
return a;
|
|
|
|
};
|
|
|
|
return A;
|
|
|
|
})();
|
|
|
|
var M;
|
|
|
|
(function (M) {
|
|
|
|
M.n;
|
|
|
|
})(M || (M = {}));
|
|
|
|
var objA = new A();
|
2014-08-12 00:54:12 +02:00
|
|
|
// any other type var
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsNumber1 = +ANY1;
|
|
|
|
var ResultIsNumber2 = +ANY2;
|
|
|
|
var ResultIsNumber3 = +A;
|
|
|
|
var ResultIsNumber4 = +M;
|
|
|
|
var ResultIsNumber5 = +obj;
|
|
|
|
var ResultIsNumber6 = +obj1;
|
2014-08-12 00:54:12 +02:00
|
|
|
// any type literal
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsNumber7 = +undefined;
|
|
|
|
var ResultIsNumber8 = +null;
|
2014-08-12 00:54:12 +02:00
|
|
|
// any type expressions
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsNumber9 = +ANY2[0];
|
|
|
|
var ResultIsNumber10 = +obj1.x;
|
|
|
|
var ResultIsNumber11 = +obj1.y;
|
|
|
|
var ResultIsNumber12 = +objA.a;
|
|
|
|
var ResultIsNumber13 = +M.n;
|
|
|
|
var ResultIsNumber14 = +foo();
|
|
|
|
var ResultIsNumber15 = +A.foo();
|
|
|
|
var ResultIsNumber16 = +(ANY + ANY1);
|
|
|
|
var ResultIsNumber17 = +(null + undefined);
|
|
|
|
var ResultIsNumber18 = +(null + null);
|
|
|
|
var ResultIsNumber19 = +(undefined + undefined);
|
2014-08-16 00:49:09 +02:00
|
|
|
// miss assignment operators
|
2014-07-13 01:04:16 +02:00
|
|
|
+ANY;
|
|
|
|
+ANY1;
|
|
|
|
+ANY2[0];
|
|
|
|
+ANY, ANY1;
|
|
|
|
+objA.a;
|
|
|
|
+M.n;
|