Skip to content

Commit d396830

Browse files
committed
add error showing where prop was also declared if is a dup
1 parent f70f8eb commit d396830

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6289,7 +6289,7 @@ namespace ts {
62896289
// report an error at each declaration.
62906290
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
62916291
const name = (<LiteralType>type).value || declarationNameToString(decl.name);
6292-
forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_property_0, name));
6292+
forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
62936293
error(decl.name || decl, Diagnostics.Duplicate_property_0, name);
62946294
lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late);
62956295
}

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,6 +2485,10 @@
24852485
"category": "Error",
24862486
"code": 2732
24872487
},
2488+
"Property '{0}' was also declared here.": {
2489+
"category": "Error",
2490+
"code": 2733
2491+
},
24882492
"It is highly likely that you are missing a semicolon.": {
24892493
"category": "Error",
24902494
"code": 2734

tests/baselines/reference/dynamicNamesErrors.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2718: Duplicate property '1'.
2-
tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2718: Duplicate property '1'.
2+
tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2733: Property '1' was also declared here.
33
tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2717: Subsequent property declarations must have the same type. Property '[c1]' must be of type 'number', but here has type 'string'.
44
tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not assignable to type 'T1'.
55
Types of property '[c0]' are incompatible.
@@ -19,7 +19,7 @@ tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T1' is not
1919
!!! error TS2718: Duplicate property '1'.
2020
1: number;
2121
~
22-
!!! error TS2718: Duplicate property '1'.
22+
!!! error TS2733: Property '1' was also declared here.
2323
}
2424

2525
interface T1 {

0 commit comments

Comments
 (0)