koSakano/type-challenges

847 - String Join

Opened this issue · 0 comments

type Join<T, U extends string> = T extends string[] ? T extends [infer V, ...infer W] ? W extends [] ? V : `${V & string}${U}${Join<W, U>}` : '' : never;

declare function join<U extends string>(delimiter: U): <V extends string[]>(...parts: V) => Join<V, U>;