Appearance
题目
实现高级工具类型 UnionToIntersection<U>
UnionToIntersection<U>
例如
type I = UnionToIntersection<"foo" | 42 | true>; // expected to be 'foo' & 42 & true
解答
type UnionToIntersection<U> = ( U extends any ? (arg: U) => any : never ) extends (arg: infer I) => void ? I : never;