From d396830386f7adc1c2bb606f0dccb44884fe193c Mon Sep 17 00:00:00 2001 From: Collins Abitekaniza Date: Tue, 16 Oct 2018 21:48:47 +0300 Subject: [PATCH] add error showing where prop was also declared if is a dup --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 4 ++++ tests/baselines/reference/dynamicNamesErrors.errors.txt | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c9065c96be1..6c276eb8638 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6289,7 +6289,7 @@ namespace ts { // report an error at each declaration. const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; const name = (type).value || declarationNameToString(decl.name); - forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_property_0, name)); + forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name)); error(decl.name || decl, Diagnostics.Duplicate_property_0, name); lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 92ae359e1d2..941d3f6053c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2485,6 +2485,10 @@ "category": "Error", "code": 2732 }, + "Property '{0}' was also declared here.": { + "category": "Error", + "code": 2733 + }, "It is highly likely that you are missing a semicolon.": { "category": "Error", "code": 2734 diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt index cdc5cef7f8d..c39140dbd52 100644 --- a/tests/baselines/reference/dynamicNamesErrors.errors.txt +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2718: Duplicate property '1'. -tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2718: Duplicate property '1'. +tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2733: Property '1' was also declared here. 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'. tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not assignable to type 'T1'. Types of property '[c0]' are incompatible. @@ -19,7 +19,7 @@ tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T1' is not !!! error TS2718: Duplicate property '1'. 1: number; ~ -!!! error TS2718: Duplicate property '1'. +!!! error TS2733: Property '1' was also declared here. } interface T1 {