typeas
Version:
Library for checking data values and type safety
7 lines (5 loc) • 304 B
TypeScript
type Join<S extends readonly string[], D extends string, F extends boolean = true> = S extends readonly [
infer A extends string,
...infer B extends string[]
] ? `${F extends true ? "" : A extends "" ? "" : D}${A}${B["length"] extends 0 ? "" : Join<B, D, false>}` : never;
export type { Join };