-
Notifications
You must be signed in to change notification settings - Fork 12.8k
"No repeated property names" error in object literals is duplicated in strict mode #46929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
tests/baselines/reference/duplicatePropertiesInStrictMode.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
tests/cases/compiler/duplicatePropertiesInStrictMode.ts(4,3): error TS1117: An object literal cannot have multiple properties with the same name in strict mode. | ||
tests/cases/compiler/duplicatePropertiesInStrictMode.ts(4,3): error TS2300: Duplicate identifier 'x'. | ||
tests/cases/compiler/duplicatePropertiesInStrictMode.ts(4,3): error TS1117: An object literal cannot have multiple properties with the same name. | ||
|
||
|
||
==== tests/cases/compiler/duplicatePropertiesInStrictMode.ts (2 errors) ==== | ||
==== tests/cases/compiler/duplicatePropertiesInStrictMode.ts (1 errors) ==== | ||
"use strict"; | ||
var x = { | ||
x: 1, | ||
x: 2 | ||
~ | ||
!!! error TS1117: An object literal cannot have multiple properties with the same name in strict mode. | ||
~ | ||
!!! error TS2300: Duplicate identifier 'x'. | ||
!!! error TS1117: An object literal cannot have multiple properties with the same name. | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/noRepeatedPropertyNames.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
tests/cases/compiler/noRepeatedPropertyNames.ts(2,23): error TS1117: An object literal cannot have multiple properties with the same name. | ||
tests/cases/compiler/noRepeatedPropertyNames.ts(5,32): error TS1117: An object literal cannot have multiple properties with the same name. | ||
|
||
|
||
==== tests/cases/compiler/noRepeatedPropertyNames.ts (2 errors) ==== | ||
// https://github.com/microsoft/TypeScript/issues/46815 | ||
const first = { a: 1, a: 2 }; | ||
~ | ||
!!! error TS1117: An object literal cannot have multiple properties with the same name. | ||
class C { | ||
m() { | ||
const second = { a: 1, a: 2 }; | ||
~ | ||
!!! error TS1117: An object literal cannot have multiple properties with the same name. | ||
return second.a; | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//// [noRepeatedPropertyNames.ts] | ||
// https://github.com/microsoft/TypeScript/issues/46815 | ||
const first = { a: 1, a: 2 }; | ||
class C { | ||
m() { | ||
const second = { a: 1, a: 2 }; | ||
return second.a; | ||
} | ||
} | ||
|
||
|
||
//// [noRepeatedPropertyNames.js] | ||
// https://github.com/microsoft/TypeScript/issues/46815 | ||
var first = { a: 1, a: 2 }; | ||
var C = /** @class */ (function () { | ||
function C() { | ||
} | ||
C.prototype.m = function () { | ||
var second = { a: 1, a: 2 }; | ||
return second.a; | ||
}; | ||
return C; | ||
}()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
=== tests/cases/compiler/noRepeatedPropertyNames.ts === | ||
// https://github.com/microsoft/TypeScript/issues/46815 | ||
const first = { a: 1, a: 2 }; | ||
>first : Symbol(first, Decl(noRepeatedPropertyNames.ts, 1, 5)) | ||
>a : Symbol(a, Decl(noRepeatedPropertyNames.ts, 1, 15), Decl(noRepeatedPropertyNames.ts, 1, 21)) | ||
>a : Symbol(a, Decl(noRepeatedPropertyNames.ts, 1, 15), Decl(noRepeatedPropertyNames.ts, 1, 21)) | ||
|
||
class C { | ||
>C : Symbol(C, Decl(noRepeatedPropertyNames.ts, 1, 29)) | ||
|
||
m() { | ||
>m : Symbol(C.m, Decl(noRepeatedPropertyNames.ts, 2, 9)) | ||
|
||
const second = { a: 1, a: 2 }; | ||
>second : Symbol(second, Decl(noRepeatedPropertyNames.ts, 4, 13)) | ||
>a : Symbol(a, Decl(noRepeatedPropertyNames.ts, 4, 24), Decl(noRepeatedPropertyNames.ts, 4, 30)) | ||
>a : Symbol(a, Decl(noRepeatedPropertyNames.ts, 4, 24), Decl(noRepeatedPropertyNames.ts, 4, 30)) | ||
|
||
return second.a; | ||
>second.a : Symbol(a, Decl(noRepeatedPropertyNames.ts, 4, 24), Decl(noRepeatedPropertyNames.ts, 4, 30)) | ||
>second : Symbol(second, Decl(noRepeatedPropertyNames.ts, 4, 13)) | ||
>a : Symbol(a, Decl(noRepeatedPropertyNames.ts, 4, 24), Decl(noRepeatedPropertyNames.ts, 4, 30)) | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
=== tests/cases/compiler/noRepeatedPropertyNames.ts === | ||
// https://github.com/microsoft/TypeScript/issues/46815 | ||
const first = { a: 1, a: 2 }; | ||
>first : { a: number; } | ||
>{ a: 1, a: 2 } : { a: number; } | ||
>a : number | ||
>1 : 1 | ||
>a : number | ||
>2 : 2 | ||
|
||
class C { | ||
>C : C | ||
|
||
m() { | ||
>m : () => number | ||
|
||
const second = { a: 1, a: 2 }; | ||
>second : { a: number; } | ||
>{ a: 1, a: 2 } : { a: number; } | ||
>a : number | ||
>1 : 1 | ||
>a : number | ||
>2 : 2 | ||
|
||
return second.a; | ||
>second.a : number | ||
>second : { a: number; } | ||
>a : number | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.