Union to Intersection
约 94 字小于 1 分钟
2026-02-11
题目
实现高级工具类型 UnionToIntersection<U>
例如
type I = UnionToIntersection<'foo' | 42 | true> // expected to be 'foo' & 42 & true解题思路
待补充
答案
type UnionToIntersection<U> = any验证
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)>>,
]参考
无
