I would like to exclude some substring from a Template Literal Type (available since TypeScript 4.1), but I don't know if it's possible.
Example:
I can define a type saying "this string is a tuple-like with 2 or more elements", ie something like '[string, number]' with this literal type :
type TupleWithTwoOrMoreElements = `[${string}, ${string}]`;
Now, I would like to do the contrary, ie creating a literal type saying "this is a tuple-like which have less than 2 elements" by excluding the substring , . I thought to do something like this :
type TupleWithLessThanTwoElements = `[${someStringWithoutCommaOrSpace}]`;
I think that it's not possible to write this kind of "regex-literal-type", but I would like to know if someone would be able to solve this problem.