You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var a: Number = new Number(1);
var b: Number = new Number(2);
var c: number = 3;
console.log(a+b);
console.log(b+c);
When compiled, the compiler produces these errors:
index.ts(4,13): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
index.ts(5,13): error TS2365: Operator '+' cannot be applied to types 'Number' and 'number'.
But if I don't use --noEmitOnError, the compiler produces this index.js:
var a = new Number(1);
var b = new Number(2);
var c = 3;
console.log(a + b);
console.log(b + c);
Which I can run with node and get expected results:
$ node index.js
3
5
Why does the compiler refuse to allow addition of two Numbers, or a Number and a number?