Union to Intersection
提出詳細
type UnionToFunction<T> = T extends any ? (arg: T) => any : never; type UnionToIntersection<U> = UnionToFunction<U> extends (arg: infer T) => any ? T : never;
提出日時 | 2023-08-13 11:28:36 |
---|---|
問題 | Union to Intersection |
ユーザー | tekihei2317 |
ステータス | 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)>>, ]