Let's say I have a constant number defined, e.g.:
const a = 3;
Why does TypeScript complain about this?
const b: 10 = a * 3 + 1;
Type 'number' is not assignable to type '10'
In the generic case, I'd like b
to have a defined set of allowed values, e.g. 10 | 16 | 19 | 25
, and I'd like TypeScript to allow:
const a = 3; // or 5, 6, 8
and error with all other a
s.
Is this possible?