Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 632 Bytes

union-to-intersection.md

File metadata and controls

24 lines (16 loc) · 632 Bytes
category alias
Generate Object
Union2Intersection UToI U2I

UnionToIntersection

Get intersection type given union type U.

Usage

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

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

// Expect: { name: string } & { age: number } & { visible: boolean } // [!code highlight]
type UnionToIntersectionProps = UnionToIntersection<Props>

// Expect: 'foo' & 42 & true // [!code highlight]
type Case = UnionToIntersection<'foo' | 42 | true>