Skip to content

compat/merge behavior differs from lodash-es when object contains Date object #1547

@imonmandal

Description

@imonmandal

Reproduction

Code:

import { merge as esMerge } from "es-toolkit/compat";
import { merge as ldMerge } from "lodash-es";

const target = { a: 1, b: { x: 1, y: 2 }, c: new Date("2025-01-01") };
const source = { b: { y: 3, z: 4 }, c: new Date("2000-01-01") };

const resultEs = esMerge({}, target, source);
const resultLd = ldMerge({}, target, source);

console.log("es-toolkit/compat", resultEs);
console.log("lodash-es", resultLd);

Output:
es-toolkit/compat { a: 1, b: { x: 1, y: 3, z: 4 }, c: 2025-01-01T00:00:00.000Z }
lodash-es { a: 1, b: { x: 1, y: 3, z: 4 }, c: 2000-01-01T00:00:00.000Z }

Actual Result: Date object from the source is not merged into target object
Expected Result: Date object from the source is merged into target object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions