Skip to content

fix(38295): Duplicated object key in const not detected when the key is a number preceded by - or + - #38607

Merged
Nathan Shively-Sanders (sandersn) merged 2 commits into
microsoft:masterfrom
a-tarasyuk:bug/38295
May 20, 2020
Merged

Nathan Shively-Sanders (sandersn) merged 2 commits into
microsoft:masterfrom
a-tarasyuk:bug/38295

Conversation

@a-tarasyuk

Copy link
Copy Markdown
Contributor

Fixes #38295

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The positive case is more complicated than the current implementation.

!!! error TS2300: Duplicate identifier '[-1]'.
}

const c = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be an error; at least on node it's fine:

> { "+1": 1, [+1]: 2 }
{ '1': 2, '+1': 1 }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this case should instead be "1"/[+1] and also 1/[+1].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nathan Shively-Sanders (@sandersn) Thanks for the feedback

@sandersn Nathan Shively-Sanders (sandersn) added the For Backlog Bug PRs that fix a backlog bug label May 19, 2020
@sandersn
Nathan Shively-Sanders (sandersn) merged commit 3340142 into microsoft:master May 20, 2020
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Duplicated object key in const not detected when the key is a number preceded by - or +

2 participants