TypeScript Version: 2.0.2.0
Code I know the code is a bit stupid, but I actually have these kind of tests in my code (making an expression visitor) and I really think these should fly and compile right away.
var a: boolean = (true == false);
var b: boolean = (5 == 2);
Instead it complains that operand equal cannot be applied to types 'true', 'false', '5' and '2'. Mark that they are not boolean or number, they are actually a types of 'true','false','5','2'. I know that types 'string' and 'boolean' cannot be compared, but hey, 5 is actually a number, not type '5' or am I mistaken?
This compiles though.
let x = 2;
var a: boolean = 5 == x;
var b: boolean = <number>5 == <number>2;
Am I missing something, why arent't 5 and 2 considered as type 'number' ?
Expected behavior: Should compile
Actual behavior: Results in a compile error saying 'Operand '==' cannot be applied to types '<first argument>' and '<second argument>'
Background I came over this issues in typescript defining that it should be like this, but how come? https://github.com/Microsoft/TypeScript/issues/6167