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