-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
by adding the magical UnionToIntersection
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void)
? I
: never;
Ref: https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
Will give you a new feature and can replace :
export type IntersectTuple<T extends Vector<any>> =
Length<T> extends 1 ? T[0] :
Length<T> extends 2 ? T[0] & T[1] :
Length<T> extends 3 ? T[0] & T[1] & T[2] :
Length<T> extends 4 ? T[0] & T[1] & T[2] & T[3] :
Length<T> extends 5 ? T[0] & T[1] & T[2] & T[3] & T[4] :
Length<T> extends 6 ? T[0] & T[1] & T[2] & T[3] & T[4] & T[5] :
Length<T> extends 7 ? T[0] & T[1] & T[2] & T[3] & T[4] & T[5] & T[6] :
Length<T> extends 8 ? T[0] & T[1] & T[2] & T[3] & T[4] & T[5] & T[6] & T[7] :
Length<T> extends 9 ? T[0] & T[1] & T[2] & T[3] & T[4] & T[5] & T[6] & T[7] & T[8] :
Length<T> extends 10 ? T[0] & T[1] & T[2] & T[3] & T[4] & T[5] & T[6] & T[7] & T[8] & T[9] :
any;
with:
export type IntersectTuple<T extends Vector<any>>=UnionToIntersection<T[number]>
Metadata
Metadata
Assignees
Labels
No labels