Skip to content

Instantly share code, notes, and snippets.

@sebinsua
Last active August 10, 2022 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebinsua/07cd2dfdcd97ca10492ea650d100d7c7 to your computer and use it in GitHub Desktop.
Save sebinsua/07cd2dfdcd97ca10492ea650d100d7c7 to your computer and use it in GitHub Desktop.
type GetTail<Items extends string[]> = Items extends [any, ...infer Tail]
? Tail
: string[];
type HasTail<Items extends string[]> = Items extends [any, any, ...any[]]
? true
: false;
type Join<Strs extends string[], Delimiter extends string = ""> = HasTail<Strs> extends false
? Strs[0] extends string ? Strs[0] : ''
: Strs extends string[] ? `${Strs[0]}${Delimiter}${Join<GetTail<Strs>, Delimiter>}` : '' ;
type Goal = Join<["Make", "anxiety", "work", "for", "you!"], ' '>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment