numeric literal types disrespect arithmetics
zpdDG4gta8XKpMCd opened this issue · 5 comments
declare var a : -1 | 0 | 1;
a = -a; // <-- problem
#26382 has been determined to be a duplicate of this, although that one is about allowing arithmetic at the type level at all, while this one seems to be more concerned with inference and flow.
Anyway, I think that now that tuple types are becoming more powerful it might be reasonable to revisit this idea so that we can get closer to the sort of dependent types needed for strongly typing such methods as Function['bind']. (Related to #26223)
There are Inc<> and Dec<> (typical) and Minus<> (ts-toolbelt).
It is critical in doing type manipulation.
The custom implementation has limitation and not efficient at all.
With intrinsic in TypeScript 4.1, it would be great if TypeScript can provide those base types.