Created
September 4, 2023 07:45
-
-
Save crutchcorn/79a6dbd3bdac4a2709323bc6e2502fc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ["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