Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 611 Bytes

File metadata and controls

43 lines (31 loc) · 611 Bytes

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 Parameters

Type Parameter Description

T

The union type to convert.

Returns

The intersection of the types in the union.

Example

// { a: number } & { b: string }
type Intersect = UnionToIntersection<{ a: number } | { b: string }>;