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