Type Challenges Judge

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