Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardTypeScriptinference internalsSingle-choice MCQ

Why does this `UnionToIntersection` helper turn a union into an intersection?

type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; type UI = UnionToIntersection<{ a: 1 } | { b: 2 }>;