2014-07-13 01:04:16 +02:00
|
|
|
//// [additionOperatorWithNullValueAndValidOperator.ts]
|
|
|
|
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
|
|
|
|
|
|
|
enum E { a, b, c }
|
|
|
|
|
|
|
|
var a: any;
|
|
|
|
var b: number;
|
|
|
|
var c: E;
|
|
|
|
var d: string;
|
|
|
|
|
|
|
|
// null + any
|
|
|
|
var r1: any = null + a;
|
|
|
|
var r2: any = a + null;
|
|
|
|
|
|
|
|
// null + number/enum
|
|
|
|
var r3 = null + b;
|
|
|
|
var r4 = null + 1;
|
|
|
|
var r5 = null + c;
|
|
|
|
var r6 = null + E.a;
|
|
|
|
var r7 = null + E['a'];
|
|
|
|
var r8 = b + null;
|
|
|
|
var r9 = 1 + null;
|
|
|
|
var r10 = c + null
|
|
|
|
var r11 = E.a + null;
|
|
|
|
var r12 = E['a'] + null;
|
|
|
|
|
|
|
|
// null + string
|
|
|
|
var r13 = null + d;
|
|
|
|
var r14 = null + '';
|
|
|
|
var r15 = d + null;
|
|
|
|
var r16 = '' + null;
|
|
|
|
|
|
|
|
//// [additionOperatorWithNullValueAndValidOperator.js]
|
2014-08-14 15:48:40 +02:00
|
|
|
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
2014-07-13 01:04:16 +02:00
|
|
|
var E;
|
|
|
|
(function (E) {
|
|
|
|
E[E["a"] = 0] = "a";
|
|
|
|
E[E["b"] = 1] = "b";
|
|
|
|
E[E["c"] = 2] = "c";
|
|
|
|
})(E || (E = {}));
|
|
|
|
var a;
|
|
|
|
var b;
|
|
|
|
var c;
|
|
|
|
var d;
|
2014-08-12 00:54:12 +02:00
|
|
|
// null + any
|
2014-07-13 01:04:16 +02:00
|
|
|
var r1 = null + a;
|
|
|
|
var r2 = a + null;
|
2014-08-12 00:54:12 +02:00
|
|
|
// null + number/enum
|
2014-07-13 01:04:16 +02:00
|
|
|
var r3 = null + b;
|
|
|
|
var r4 = null + 1;
|
|
|
|
var r5 = null + c;
|
|
|
|
var r6 = null + 0 /* a */;
|
2014-11-02 02:16:48 +01:00
|
|
|
var r7 = null + 0 /* 'a' */;
|
2014-07-13 01:04:16 +02:00
|
|
|
var r8 = b + null;
|
|
|
|
var r9 = 1 + null;
|
|
|
|
var r10 = c + null;
|
|
|
|
var r11 = 0 /* a */ + null;
|
2014-11-02 02:16:48 +01:00
|
|
|
var r12 = 0 /* 'a' */ + null;
|
2014-08-12 00:54:12 +02:00
|
|
|
// null + string
|
2014-07-13 01:04:16 +02:00
|
|
|
var r13 = null + d;
|
|
|
|
var r14 = null + '';
|
|
|
|
var r15 = d + null;
|
|
|
|
var r16 = '' + null;
|