UnionToTuple
All checks were successful
Lint / lint (push) Successful in 12s

This commit is contained in:
Julien Valverdé
2024-08-21 03:20:38 +02:00
parent c0433a8c76
commit 70bf951c19
2 changed files with 11 additions and 0 deletions

10
src/Types/UnionToTuple.ts Normal file
View File

@@ -0,0 +1,10 @@
import type { UnionToIntersection } from "type-fest"
type LastOf<T> = UnionToIntersection<T extends any ? (x: T) => void : never> extends (x: infer Last) => void
? Last
: never
export type UnionToTuple<T, Last = LastOf<T>> = [T] extends [never]
? []
: [...UnionToTuple<Exclude<T, Last>>, Last]

View File

@@ -3,3 +3,4 @@ export * from "./Extend"
export * from "./Merge" export * from "./Merge"
export * as PrismaJson from "./PrismaJson" export * as PrismaJson from "./PrismaJson"
export * from "./StaticType" export * from "./StaticType"
export * from "./UnionToTuple"