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

    Type Alias CommonUpcastPairs<T, U>

    CommonUpcastPairs: {
        [K in keyof T & keyof U as T[K] extends U[K]
            ? U[K] extends T[K] ? K : K
            : U[K] extends T[K]
                ? K
                : IsUpcastable<T[K]> extends true
                    ? IsUpcastable<U[K]> extends true
                        ? GetUpcastable<T[K]> extends GetUpcastable<U[K]> ? K : never
                        : never
                    : never]: T[K] extends U[K]
            ? U[K] extends T[K] ? T[K] : U[K]
            : U[K] extends T[K]
                ? T[K]
                : IsUpcastable<T[K]> extends true
                    ? IsUpcastable<U[K]> extends true
                        ? GetUpcastable<T[K]> extends GetUpcastable<U[K]>
                            ? GetUpcastable<T[K]>
                            : never
                        : never
                    : never
    }

    Finds common properties between two types with primitive literal upcasting.

    Properties are included if:

    1. Types are exactly identical, or
    2. One type is more general than the other (e.g., string vs 'literal'), or
    3. Both are primitive literals that can be upcast to the same base type

    Type Selection Priority: When types can be unified, the more general type is chosen to ensure maximum compatibility (e.g., string over 'cat'). This maintains upcasting behavior in recursive scenarios.

    Type Parameters

    • T

      First type

    • U

      Second type

    Object type with common properties, preferring general types when possible

    interface A { name: string; type: 'cat'; active: true; }
    interface B { name: string; type: 'dog'; active: false; }

    type Result = CommonUpcastPairs<A, B>;
    // { name: string; type: string; active: boolean }
    // 'type': 'cat' | 'dog' → string (upcast to common base)
    // 'active': true | false → boolean (upcast to common base)

    // Type priority example:
    type Mixed = CommonUpcastPairs<{prop: string}, {prop: 'literal'}>;
    // Result: {prop: string} - chooses more general type