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
Props
= {
name
: string } | {
age
: number } | {
visible
: boolean }
// Expect: { name: string } & { age: number } & { visible: boolean } type
UnionToIntersectionProps
=
UnionToIntersection
<
Props
>
// Expect: 'foo' & 42 & true type
Case
=
UnionToIntersection
<'foo' | 42 | true>