Skip to content

Object literals allow duplicate [Enum.member]: ... keys #49666

Description

@pushkine

Bug Report

🕗 Version & Regression Information

ts stable & nightly

⏯ Playground Link

Playground Link

💻 Code

const x = {
    [1]: 2,
    [1]: 2,
//  ^^^ ERROR: An object literal cannot have multiple properties with the same name. (1117)
};

enum Enum { foo = 1, }

const y = {
    [Enum.foo]: 2,
    [Enum.foo]: 2,
//  ^^^^^^^^^^ No Error
};

🙁 Actual behavior

Defining an object literal with duplicate keys throws an error for literal 1 but not for enum member Enum.foo

🙂 Expected behavior

Defining an object with duplicate keys from enum members throws an error

    [Enum.foo]: 2,
    [Enum.foo]: 2,
//  ^^^^^^^^^^ An object literal cannot have multiple properties with the same name

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions