Type alias UnionToIntersection<U>

UnionToIntersection<U>: (U extends U
        ? ((x) => unknown)
        : never) extends ((x) => unknown)
    ? R
    : never

The UnionToIntersection type in TypeScript is used to convert a union type to an intersection type. This can be useful when you have a union type that contains multiple types, and you want to use the properties of all of those types in a single type or value.

Type Parameters

  • U

Example

 const data: UnionToIntersection<{ a: string } | { b: string }> = { a: 'hello', b: 'world' }