UnionToIntersection<U>
ts
type UnionToIntersection<U> = U extends unknown ? (k) => void : never extends (k) => void ? I : never;Defined in: types.ts:16
Converts a union type to an intersection type.
Type Parameters
| Type Parameter | Description |
|---|---|
U | The union type to convert |
Example
ts
type Union = { a: string } | { b: number };
type Result = UnionToIntersection<Union>;
// Result: { a: string } & { b: number }