import type { Args, Fn } from "../HKT"; /** * Convert a union type to an intersection type. * * Sig: `(u: UnionOf) => IntersectOf` */ export type ToIntersection = (U extends unknown ? (_: U) => void : never) extends (mergedIntersection: infer I) => void ? I & U // The `& U` is to allow indexing by the resulting type : never; /** * [Fn] Convert a union type to an intersection type. * * Sig: `(u: UnionOf) => IntersectOf` */ export default interface ToIntersectionFn extends Fn<[unknown], unknown> { def: ([u]: Args) => ToIntersection; }