Skip to content

UnionToIntersection

Category
Generate Object
Alias
Union2IntersectionUToIU2I

Get intersection type given union type U.

Usage

ts
import type { UnionToIntersection } from '@utype/core'

type Prop = { name: string } | { age: number } | { visible: boolean }

// Expect: { name: string } & { age: number } & { visible: boolean }
type UnionToIntersectionProp = UnionToIntersection<Prop>

// Expect: 'foo' & 42 & true
type Case = UnionToIntersection<'foo' | 42 | true>