Untitled
unknown
typescript
a year ago
443 B
6
Indexable
// This is tricky because you cannot do Str extends `${infer Before}${UnionOfSep}${infer After}` ... type Split<Str, UnionOfSep extends string, CurrentWord extends string = "", Output extends string[] = []> = Str extends `${infer First}${infer Rest}` ? First extends UnionOfSep ? Split<Rest, UnionOfSep, "", [...Output, CurrentWord]> : Split<Rest, UnionOfSep, `${CurrentWord}${First}`, Output> : [...Output, CurrentWord];
Editor is loading...
Leave a Comment