"No repeated property names" error in object literals is duplicated in strict mode (#46929)

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

* fix indent
This commit is contained in:
Yuki Osaki
2021-12-07 03:22:28 +09:00
committed by GitHub
parent 97a7901f26
commit 1f275d705d
20 changed files with 197 additions and 100 deletions

View File

@@ -2066,12 +2066,6 @@ namespace ts {
seen.set(identifier.escapedText, currentKind);
continue;
}
if (currentKind === ElementKind.Property && existingKind === ElementKind.Property) {
const span = getErrorSpanForNode(file, identifier);
file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length,
Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode));
}
}
}

View File

@@ -43126,9 +43126,12 @@ namespace ts {
seen.set(effectiveName, currentKind);
}
else {
if ((currentKind & DeclarationMeaning.PropertyAssignmentOrMethod) && (existingKind & DeclarationMeaning.PropertyAssignmentOrMethod)) {
if ((currentKind & DeclarationMeaning.Method) && (existingKind & DeclarationMeaning.Method)) {
grammarErrorOnNode(name, Diagnostics.Duplicate_identifier_0, getTextOfNode(name));
}
else if ((currentKind & DeclarationMeaning.PropertyAssignment) && (existingKind & DeclarationMeaning.PropertyAssignment)) {
grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, getTextOfNode(name));
}
else if ((currentKind & DeclarationMeaning.GetOrSetAccessor) && (existingKind & DeclarationMeaning.GetOrSetAccessor)) {
if (existingKind !== DeclarationMeaning.GetOrSetAccessor && currentKind !== existingKind) {
seen.set(effectiveName, currentKind | existingKind);

View File

@@ -335,7 +335,7 @@
"category": "Error",
"code": 1116
},
"An object literal cannot have multiple properties with the same name in strict mode.": {
"An object literal cannot have multiple properties with the same name.": {
"category": "Error",
"code": 1117
},