/** Primitives we never merge */ type Primitive = string | number | boolean | bigint | symbol | null | undefined; /** A safe callable type (instead of `Function`) */ type AnyFn = (...args: readonly unknown[]) => unknown; /** * Things we do NOT deep-merge (we overwrite instead). * Add more here if your domain needs them (URL, Buffer, TypedArrays, etc.) */ type NonMergeable = Primitive | AnyFn | Date | RegExp | Map | Set | WeakMap | WeakSet | Promise | readonly unknown[]; type IsPlainObject = T extends object ? T extends NonMergeable ? false : true : false; type Simplify = { [K in keyof T]: T[K]; } & Record; /** Merge two object types; last wins for non-plain objects */ type MergeTwoTypes = IsPlainObject extends true ? IsPlainObject extends true ? Simplify<{ [K in keyof A | keyof B]: K extends keyof B ? K extends keyof A ? MergeValue : B[K] : K extends keyof A ? A[K] : never; }> : B : B; type MergeValue = IsPlainObject extends true ? IsPlainObject extends true ? MergeTwoTypes : BV : BV; /** Fold a tuple of objects left-to-right */ type DeepMergeTuple = T extends readonly [infer A, ...infer R] ? R extends readonly unknown[] ? MergeTwoTypes> : A : Record; export type DeepMergeResult = Simplify>; /** * Deep merge any number of objects. * - Deep merges *plain objects* only. * - Overwrites arrays and class instances. * - Later args win. */ export declare function deepMerge(...objects: T): DeepMergeResult; export {}; //# sourceMappingURL=deepmerge.d.ts.map