00055-hard-union-to-intersection
Hard
utils
infer

Implement the advanced util type UnionToIntersection<U>

For example

type I = UnionToIntersection<'foo' | 42 | true> // expected to be 'foo' & 42 & true

Loading...
import type { Equal, Expect } from '@type-challenges/utils'

type cases = [
  Expect<Equal<UnionToIntersection<'foo' | 42 | true>, 'foo' & 42 & true>>,
  Expect<Equal<UnionToIntersection<(() => 'foo') | ((i: 42) => true)>, (() => 'foo') & ((i: 42) => true)>>,
]