UNPKG

type-enhancers

Version:
10 lines (9 loc) 398 B
export type SplitByString<Source extends string, Separator extends string> = Source extends `${infer Left}${Separator}${infer Right}` ? [...(string extends Left ? string[] : [`${Left}`]), ...SplitByString<Right, Separator>] : Source extends '' ? Separator extends '' ? [] : [''] : string extends Source ? string[] : [Source];