Skip to content

Instantly share code, notes, and snippets.

@crutchcorn
Created September 4, 2023 07:45
Show Gist options
  • Save crutchcorn/79a6dbd3bdac4a2709323bc6e2502fc9 to your computer and use it in GitHub Desktop.
Save crutchcorn/79a6dbd3bdac4a2709323bc6e2502fc9 to your computer and use it in GitHub Desktop.
/**
* ["a", "b", "c"] => ["a" | "b" | "c", "a" | "b" | "c", "a" | "b" | "c"]
*
* Assumes keys are unique
*/
export type LoosenTuple<
Arr extends readonly any[],
OriginalArr extends readonly any[] = Arr,
> = Arr extends readonly [unknown, ...infer Tail]
? readonly [OriginalArr[number], ...LoosenTuple<Tail, OriginalArr>]
: readonly []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment