Skip to content

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

@pushkine

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
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions