Skip to content

Symbol keys are not merged #145

@tchin25

Description

@tchin25

Environment

$ node -v
v20.13.1

Reproduction

const [a, b, c] = [Symbol("a"), Symbol("b"), Symbol("c")];
const result = defu({ [a]: "a", [c]: ["a", "b"] }, { [a]: "bbb", [b]: "c", [c]: ["c", "d"] });
expect(result).toEqual({ [a]: "a", [b]: "c", [c]: ["a", "b", "c", "d"] });
AssertionError: expected { [Symbol(a)]: 'bbb', …(2) } to deeply equal { [Symbol(a)]: 'a', …(2) }

- Expected
+ Received

  Object {
-   Symbol(a): "a",
+   Symbol(a): "bbb",
    Symbol(b): "c",
    Symbol(c): Array [
-     "a",
-     "b",
      "c",
      "d",
    ],
  }

Describe the bug

Symbol keys are not iterated over the base object, but the other objects use Object.assign which does copy symbol keys.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions