devtypes - v1.1.0
    Preparing search index...

    Type Alias DeepMerge<Left, Right>

    DeepMerge: {
        [K in keyof Left | keyof Right]: K extends keyof Right
            ? K extends keyof Left
                ? Left[K] extends ReadonlyArray<any>
                    ? Right[K]
                    : Left[K] extends object
                        ? Right[K] extends object ? DeepMerge<Left[K], Right[K]> : Right[K]
                        : Right[K]
                : Right[K]
            : K extends keyof Left ? Left[K] : never
    } & {}

    Deeply merge two object types.

    Type Parameters

    • Left

      Base object type

    • Right

      Overriding object type

    Recursively merges nested objects. On conflicts, the right-hand type always takes precedence.

    type A = { a: { x: number; y: string }; b: string };
    type B = { a: { y: number; z: boolean }; c: boolean };
    type Merged = DeepMerge< A, B >;
    // { a: { x: number; y: number; z: boolean }; b: string; c: boolean }