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 Parameter | Description |
|---|---|
|
|
The first union type. |
|
|
The second union type. |
The intersection of U1 and U2.
// 'b'
type Result = UnionIntersection<'a' | 'b', 'b' | 'c'>;