I would like to define a type that enforces each character be '1'|'0'
type Binary = '1'|'0'
this works, but only with a string length of 1. Is there any way to define the type as 1 or 0 repeating?
Also curious if there is a way to enforce length? This is the only thing I could come up with
type BinaryInput = `${Binary}${Binary}${Binary}${Binary}${Binary}`;
BinaryLength<16>orBinaryLength<32>as a big union you will have a bad time. You can make a constraint that checks a candidate type, though, but this depends on your use case. What will you do with such a type? Have it as an input to a function? Could you show a minimal reproducible example of some uses?