Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 686 Bytes

File metadata and controls

55 lines (39 loc) · 686 Bytes

typelab / utils / UnionIntersection

type UnionIntersection<U1, U2> = U1 extends U1 ? U2 extends U2 ? IsEqual<U1, U2> extends true ? U1 : never : never : never;

Get the intersection of two union types, combining only the types that exist in both unions.

Type Parameters

Type Parameter Description

U1

The first union type.

U2

The second union type.

Returns

The intersection of U1 and U2.

Example

// 'b'
type Result = UnionIntersection<'a' | 'b', 'b' | 'c'>;