Report errors from duplicate member names

This commit is contained in:
Ron Buckton
2017-04-30 22:27:31 -07:00
parent 0c1eef70b0
commit d572a54d15
9 changed files with 139 additions and 155 deletions

View File

@@ -1815,7 +1815,7 @@ namespace ts {
}
function getSymbolOfNode(node: Node): Symbol {
return getMergedSymbol(node.symbol);
return getMergedSymbol(node.symbol && node.symbol.name === "__computed" && node.id && getNodeLinks(node).resolvedSymbol || node.symbol);
}
function getParentOfSymbol(symbol: Symbol): Symbol {
@@ -19502,7 +19502,10 @@ namespace ts {
// initializer is consistent with type associated with the node
const declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) {
error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(type), typeToString(declarationType));
const message = node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature
? Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
: Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
error(node.name, message, declarationNameToString(node.name), typeToString(type), typeToString(declarationType));
}
if (node.initializer) {
checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined);

View File

@@ -2123,6 +2123,10 @@
"category": "Error",
"code": 2710
},
"Subsequent property declarations must have the same type. Property '{0}' must be of type '{1}', but here has type '{2}'.": {
"category": "Error",
"code": 2711
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",