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 (m
why aren't 5 and 2 considered as type 'number'
The have the literal type 5 and 2. e.g.
var x: 5;
// can only ever be assigned to 5
x = 5; // okay
x = 2; // Error
I don't see an actual use case for wanting it not to be an error. This is just the compiler trying to help you. Feel free to create an issue if you see sufficient motivation