Closed
Description
TypeScript Version: 2.2.1 / Playground
Code
var s10: 10 = 10;
s10++;
s10 += 1;
s10 = s10 + 1; // Type 'number' is not assignable to type '10'.
Expected behavior:
Compiler errors on all three lines
Actual behavior:
Only errors on the last line.
This looks like a clear bug. A bit more subtle case is a union of literals where increment may or may not lead to the correct type. That subtlety should probably be folded into integer types, and ignored for now. Increments and +=
on literal type should error.