68 lines
No EOL
2.4 KiB
Text
68 lines
No EOL
2.4 KiB
Text
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
|
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
|
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
|
|
|
|
|
==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (3 errors) ====
|
|
// + 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);
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
|
var ResultIsNumber18 = +(null + null);
|
|
~~~~~~~~~~~
|
|
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
|
var ResultIsNumber19 = +(undefined + undefined);
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
|
|
|
// miss assignment operators
|
|
+ANY;
|
|
+ANY1;
|
|
+ANY2[0];
|
|
+ANY, ANY1;
|
|
+objA.a;
|
|
+M.n; |