We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3554199 commit bdb7913Copy full SHA for bdb7913
1 file changed
projects/type-operations/template-literal-type-shenanigans/03-split-on/solution.ts
@@ -3,5 +3,5 @@ export type SplitOn<
3
On extends string,
4
Results extends string[] = [],
5
> = Text extends `${infer Prefix}${On}${infer Suffix}`
6
- ? SplitOn<Suffix, On, [Prefix, ...Results]>
7
- : [Text, ...Results];
+ ? SplitOn<Suffix, On, [...Results, Prefix]>
+ : [...Results, Text];
0 commit comments