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

    Type Alias CommonStrictPairs<T, U>

    CommonStrictPairs: {
        [K in keyof T & keyof U as T[K] extends U[K]
            ? U[K] extends T[K] ? K : never
            : never]: T[K] extends U[K] ? T[K] : U[K] extends T[K] ? U[K] : never
    }

    Finds common properties between two types using strict type matching.

    Properties are included only if their types are exactly identical. Properties with incompatible types are completely excluded from the result (not included with never type). Uses key remapping to filter properties at the type level.

    Type Parameters

    • T

      First type

    • U

      Second type

    Object type with only properties that have exactly matching types

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

    type Result = CommonStrictPairs<A, B>; // { name: string }
    // 'type' excluded: 'cat' !== 'dog'
    // 'active' excluded: true !== false
    // Only properties with identical types are included