Skip to content

Symbol keys are not merged #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tchin25 opened this issue Feb 20, 2025 · 0 comments · May be fixed by #146
Open

Symbol keys are not merged #145

tchin25 opened this issue Feb 20, 2025 · 0 comments · May be fixed by #146
Labels
bug Something isn't working

Comments

@tchin25
Copy link

tchin25 commented Feb 20, 2025

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

@tchin25 tchin25 added the bug Something isn't working label Feb 20, 2025
@kricsleo kricsleo linked a pull request Mar 29, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant