Skip to content

Duplicate object keys not caught when using variables #43186

Description

Bug Report

🔎 Search Terms

duplicate string identifiers
duplicate keys in object

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about duplicate/keys/properties
  • In the playground 3.3.3 doesn't have any support for duplicate keys and 3.5.1 has support for ids but this bug exists

⏯ Playground Link

Playground link with relevant code

💻 Code

const bar = "bar";

const a = {
    ["foo"]: 1,
    ["foo"]: 2, // Error
    [bar]: 3,
    [bar]: 4, // Not Error
};

🙁 Actual behavior

The second instance of bar is allowed.

🙂 Expected behavior

The second instance of bar as an input should not be allowed.

Additional

When you introduce bar as a key in any other form it causes the error I would expect with just the variables.

Playground link to this scenario

const bar = "bar";

const a = {
    ["foo"]: 1,
    ["foo"]: 2, // Error
    [bar]: 3,
    [bar]: 4, // Error
    bar: 5, // Error
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions