diff --git a/src/object.ts b/src/object.ts index b5a416c8..1e09f701 100644 --- a/src/object.ts +++ b/src/object.ts @@ -283,7 +283,10 @@ export const assign = >( override: X ): X => { if (!initial || !override) return initial ?? override ?? {} - const merged = cloneObject(initial) + const proto = Object.getPrototypeOf(initial) + const merged = proto + ? { ...initial } + : Object.assign(Object.create(proto), initial) for (const key in override) { if (hasOwnProperty(override, key)) { merged[key] = isPlainObject(initial[key])