add error showing where prop was also declared if is a dup

This commit is contained in:
Collins Abitekaniza 2018-10-16 21:48:47 +03:00
parent f70f8eb70d
commit d396830386
3 changed files with 7 additions and 3 deletions

View File

@ -6289,7 +6289,7 @@ namespace ts {
// report an error at each declaration.
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
const name = (<LiteralType>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);
}

View File

@ -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

View File

@ -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 {