typelab / utils / UnionToIntersection
type UnionToIntersection<T> = T extends T ? Fn<[T]> : never extends Fn<[infer Result]> ? Result : never;Converts a union type to an intersection type.
| Type Parameter | Description |
|---|---|
|
|
The union type to convert. |
The intersection of the types in the union.
// { a: number } & { b: string }
type Intersect = UnionToIntersection<{ a: number } | { b: string }>;