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)>>, ]