Type Challenges Judge

Union to Intersection

提出詳細

type UnionToIntersection<U> = ( U extends unknown ? (arg: U) => void : never ) extends (arg: infer I) => void ? I : never
提出日時2024-09-14 16:28:32
問題Union to Intersection
ユーザーookkoouu
ステータスAccepted
テストケース
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)>>, ]