core3-utils

@wixc3/common on Github

Home > @wixc3/common > UnionToIntersection

UnionToIntersection type

Make an intersection type from union

Signature:

export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;

Example

const a:UnionToIntersection<{a:string}|{b:string}> = {a:'ok', b:'also ok'}