Open dcollien opened 2 years ago
Can I suggest also: type oddNumber = twoMilOdd | fourMilOdd | ... etc. Where: type twoMilOdd = 1 | 3 | 5 | ... etc. So isOdd can be a type guard:
type oddNumber = twoMilOdd | fourMilOdd | ... etc.
type twoMilOdd = 1 | 3 | 5 | ... etc.
function isOdd(value: number): value is oddNumber { ... }
This is what this project has needed all along!
Also no factories or adapters.
Nice! we can get compile-time checks!
Can I suggest also:
type oddNumber = twoMilOdd | fourMilOdd | ... etc.
Where:type twoMilOdd = 1 | 3 | 5 | ... etc.
So isOdd can be a type guard: