PokéRogue
    Preparing search index...

    Type Alias UnionToIntersection<Union>

    UnionToIntersection: (
        Union extends unknown ? (distributedUnion: Union) => void : never
    ) extends (mergedIntersection: infer Intersection) => void
        ? Intersection & Union
        : never

    Convert a union type to an intersection type using distributive conditional types.

    Inspired by this Stack Overflow answer.

    Type Parameters

    • Union
    import type {UnionToIntersection} from 'type-fest';

    type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};

    type Intersection = UnionToIntersection<Union>;
    //=> {the(): void} & {great(arg: string): void} & {escape: boolean}