2014-07-13 01:04:16 +02:00
|
|
|
//// [additionOperatorWithUndefinedValueAndInvalidOperands.ts]
|
|
|
|
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
|
|
|
|
|
|
|
function foo(): void { return undefined }
|
|
|
|
|
|
|
|
var a: boolean;
|
|
|
|
var b: Object;
|
|
|
|
var c: void;
|
|
|
|
var d: Number;
|
|
|
|
|
|
|
|
// undefined + boolean/Object
|
|
|
|
var r1 = undefined + a;
|
|
|
|
var r2 = undefined + b;
|
|
|
|
var r3 = undefined + c;
|
|
|
|
var r4 = a + undefined;
|
|
|
|
var r5 = b + undefined;
|
|
|
|
var r6 = undefined + c;
|
|
|
|
|
|
|
|
// other cases
|
|
|
|
var r7 = undefined + d;
|
|
|
|
var r8 = undefined + true;
|
|
|
|
var r9 = undefined + { a: '' };
|
|
|
|
var r10 = undefined + foo();
|
|
|
|
var r11 = undefined + (() => { });
|
|
|
|
|
|
|
|
//// [additionOperatorWithUndefinedValueAndInvalidOperands.js]
|
2014-08-14 15:21:30 +02:00
|
|
|
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
2015-02-07 05:03:24 +01:00
|
|
|
function foo() { return undefined; }
|
2014-07-13 01:04:16 +02:00
|
|
|
var a;
|
|
|
|
var b;
|
|
|
|
var c;
|
|
|
|
var d;
|
2014-08-12 00:54:12 +02:00
|
|
|
// undefined + boolean/Object
|
2014-07-13 01:04:16 +02:00
|
|
|
var r1 = undefined + a;
|
|
|
|
var r2 = undefined + b;
|
|
|
|
var r3 = undefined + c;
|
|
|
|
var r4 = a + undefined;
|
|
|
|
var r5 = b + undefined;
|
|
|
|
var r6 = undefined + c;
|
2014-08-12 00:54:12 +02:00
|
|
|
// other cases
|
2014-07-13 01:04:16 +02:00
|
|
|
var r7 = undefined + d;
|
|
|
|
var r8 = undefined + true;
|
|
|
|
var r9 = undefined + { a: '' };
|
|
|
|
var r10 = undefined + foo();
|
2015-02-07 03:45:09 +01:00
|
|
|
var r11 = undefined + (function () { });
|