Skip to content

Conversation

@Yuuki77
Copy link
Contributor

@Yuuki77 Yuuki77 commented Nov 27, 2021

improved the error messages when object property name is duplicated.
smaple

// @strict: false
const first = { a: 1, a: 2 }
class C {
    m() {
        const second = { a: 1, a: 2 }
        return second.a
    }
}

before

test.ts:3:23 - error TS2300: Duplicate identifier 'a'.

3 const first = { a: 1, a: 2 };
                        ~

test.ts:6:32 - error TS1117: An object literal cannot have multiple properties with the same name in strict mode.

6         const second = { a: 1, a: 2 };
                                 ~

test.ts:6:32 - error TS2300: Duplicate identifier 'a'.

6         const second = { a: 1, a: 2 };
                                 ~

[12:48:19 PM] Found 3 errors. Watching for file changes

now

test.ts:3:23 - error TS1117: An object literal cannot have multiple properties with the same name.

3 const first = { a: 1, a: 2 };
                        ~

test.ts:6:32 - error TS1117: An object literal cannot have multiple properties with the same name.

6         const second = { a: 1, a: 2 };

this is my first pr to this project.
Let me know if there is anything I am missing 😄

Fixes #46815

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Nov 27, 2021
@Yuuki77 Yuuki77 force-pushed the fix-issue-46815 branch 5 times, most recently from 2547d20 to 961f92f Compare November 28, 2021 13:15
@Yuuki77
Copy link
Contributor Author

Yuuki77 commented Nov 28, 2021

master is failing as well 🤔

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Looks good, just need to fix indentation. (And I hope the build is no longer broken, you might have to merge from main to get that.)

@Yuuki77
Copy link
Contributor Author

Yuuki77 commented Dec 6, 2021

@sandersn thank you for the reviews!
I have updated it.
Could you take a look when you have time?

@sandersn sandersn merged commit 1f275d7 into microsoft:main Dec 6, 2021
@Yuuki77 Yuuki77 deleted the fix-issue-46815 branch December 7, 2021 00:56
mprobst pushed a commit to mprobst/TypeScript that referenced this pull request Jan 10, 2022
…n strict mode (microsoft#46929)

* "No repeated property names" error in object literals is duplicated in strict mode

* fix indent
@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

None yet

Development

Successfully merging this pull request may close these issues.

"No repeated property names" error in object literals is duplicated in strict mode

3 participants