Make sure string is hex value with stream

I would like to make sure that the value I am getting is the 6th row. I am currently speaking

type Color = string;
function foo(color: Color){}

      

But I would like to say

type Color = '#' + stringOfLength-3-6-8;
function foo(color: Color){}

      

Is there a way to express such constraints in a stream?

+3


source to share


1 answer


No, that's not what the type system can express. You can create a type that is a concatenation of literals (for example type Foo = 'foo' | 'bar' | ...

), but if you cannot list all possible strings, then you cannot accomplish what you ask.



+3


source







All Articles