CommonProps Documentation - v0.1.2
    Preparing search index...

    Type Alias CommonUpcastProps<T, Empty>

    CommonUpcastProps: T extends readonly [
        infer First,
        infer Second,
        ...(infer Rest),
    ]
        ? Rest extends readonly []
            ? CommonUpcastPairs<First, Second>
            : CommonUpcastProps<[CommonUpcastPairs<First, Second>, ...Rest]>
        : T extends readonly [infer Only] ? Only : Empty

    Finds common properties across multiple types with primitive literal upcasting.

    Recursively processes an array of types, applying upcast matching rules. Properties are included if they exist in all types and can be unified through upcasting.

    Type Parameters

    • T extends readonly unknown[]

      Array of types to find common properties for

    • Empty = {}

      Default type for empty arrays (default: {})

    Object type with common properties, upcasting literals when possible

    interface Cat { name: string; type: 'cat'; active: true; priority: 1; }
    interface Dog { name: string; type: 'dog'; active: false; priority: 2; }
    interface Bird { name: string; type: 'bird'; active: true; priority: 3; }

    type Result = CommonUpcastProps<[Cat, Dog, Bird]>;
    // { name: string; type: string; active: boolean; priority: number }
    // All literals are upcast to their primitive base types