Type Challenges Judge

Union to Intersection

提出詳細

type UnionToIntersection<U> = (U extends U ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never
提出日時2023-09-19 03:39:47
問題Union to Intersection
ユーザーsankantsu
ステータス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)>>, ]