2014-07-13 01:04:16 +02:00
|
|
|
//// [bitwiseNotOperatorWithAnyOtherType.ts]
|
|
|
|
// ~ operator on any type
|
|
|
|
|
|
|
|
var ANY: any;
|
|
|
|
var ANY1;
|
|
|
|
var ANY2: any[] = ["", ""];
|
|
|
|
var obj: () => {}
|
|
|
|
var obj1 = { x:"", y: () => { }};
|
|
|
|
|
|
|
|
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 ResultIsNumber = ~ANY1;
|
|
|
|
var ResultIsNumber1 = ~ANY2;
|
|
|
|
var ResultIsNumber2 = ~A;
|
|
|
|
var ResultIsNumber3 = ~M;
|
|
|
|
var ResultIsNumber4 = ~obj;
|
|
|
|
var ResultIsNumber5 = ~obj1;
|
|
|
|
|
|
|
|
// any type literal
|
|
|
|
var ResultIsNumber6 = ~undefined;
|
|
|
|
var ResultIsNumber7 = ~null;
|
|
|
|
|
|
|
|
// any type expressions
|
|
|
|
var ResultIsNumber8 = ~ANY2[0]
|
|
|
|
var ResultIsNumber9 = ~obj1.x;
|
|
|
|
var ResultIsNumber10 = ~obj1.y;
|
|
|
|
var ResultIsNumber11 = ~objA.a;
|
|
|
|
var ResultIsNumber12 = ~M.n;
|
|
|
|
var ResultIsNumber13 = ~foo();
|
|
|
|
var ResultIsNumber14 = ~A.foo();
|
|
|
|
var ResultIsNumber15 = ~(ANY + ANY1);
|
|
|
|
var ResultIsNumber16 = ~(null + undefined);
|
|
|
|
var ResultIsNumber17 = ~(null + null);
|
|
|
|
var ResultIsNumber18 = ~(undefined + undefined);
|
|
|
|
|
|
|
|
// multiple ~ operators
|
|
|
|
var ResultIsNumber19 = ~~ANY;
|
|
|
|
var ResultIsNumber20 = ~~~(ANY + ANY1);
|
|
|
|
|
|
|
|
//miss assignment operators
|
|
|
|
~ANY;
|
|
|
|
~ANY1;
|
|
|
|
~ANY2[0];
|
|
|
|
~ANY, ANY1;
|
|
|
|
~obj1.y;
|
|
|
|
~objA.a;
|
|
|
|
~M.n;
|
|
|
|
~~obj1.x;
|
|
|
|
|
|
|
|
//// [bitwiseNotOperatorWithAnyOtherType.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;
|
2015-02-07 03:45:09 +01:00
|
|
|
var obj1 = { x: "", y: function () { } };
|
2014-07-13 01:04:16 +02:00
|
|
|
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 ResultIsNumber = ~ANY1;
|
|
|
|
var ResultIsNumber1 = ~ANY2;
|
|
|
|
var ResultIsNumber2 = ~A;
|
|
|
|
var ResultIsNumber3 = ~M;
|
|
|
|
var ResultIsNumber4 = ~obj;
|
|
|
|
var ResultIsNumber5 = ~obj1;
|
2014-08-12 00:54:12 +02:00
|
|
|
// any type literal
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsNumber6 = ~undefined;
|
|
|
|
var ResultIsNumber7 = ~null;
|
2014-08-12 00:54:12 +02:00
|
|
|
// any type expressions
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsNumber8 = ~ANY2[0];
|
|
|
|
var ResultIsNumber9 = ~obj1.x;
|
|
|
|
var ResultIsNumber10 = ~obj1.y;
|
|
|
|
var ResultIsNumber11 = ~objA.a;
|
|
|
|
var ResultIsNumber12 = ~M.n;
|
|
|
|
var ResultIsNumber13 = ~foo();
|
|
|
|
var ResultIsNumber14 = ~A.foo();
|
|
|
|
var ResultIsNumber15 = ~(ANY + ANY1);
|
|
|
|
var ResultIsNumber16 = ~(null + undefined);
|
|
|
|
var ResultIsNumber17 = ~(null + null);
|
|
|
|
var ResultIsNumber18 = ~(undefined + undefined);
|
2014-08-12 00:54:12 +02:00
|
|
|
// multiple ~ operators
|
2014-07-13 01:04:16 +02:00
|
|
|
var ResultIsNumber19 = ~~ANY;
|
|
|
|
var ResultIsNumber20 = ~~~(ANY + ANY1);
|
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;
|
|
|
|
~obj1.y;
|
|
|
|
~objA.a;
|
|
|
|
~M.n;
|
|
|
|
~~obj1.x;
|