Package: effect
Module: Types
Transforms a union type into an intersection type.
When to use
Use to combine all members of a union into a single type with all their properties. This is useful in advanced generic code where you need to merge union variants.
Details
string | number), the
result is never.Example (Converting a union to an intersection)
import type { Types } from "effect"
type Union = { a: string } | { b: number }
type Result = Types.UnionToIntersection<Union>
// { a: string } & { b: number }
See
IsUnionSignature
type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R
: never
Since v2.0.0