Skip to content
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

Symbol keys are not merged #145

Open
tchin25 opened this issue Feb 20, 2025 · 0 comments
Open

Symbol keys are not merged #145

tchin25 opened this issue Feb 20, 2025 · 0 comments
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
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

No branches or pull requests

1 participant