@@ -5352,7 +5352,7 @@ namespace ts {
5352
5352
return type;
5353
5353
}
5354
5354
else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
5355
- errorNextVariableOrPropertyDeclarationMustHaveSameType(declaredType, declaration, type);
5355
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
5356
5356
}
5357
5357
}
5358
5358
return declaredType;
@@ -26839,7 +26839,7 @@ namespace ts {
26839
26839
if (type !== errorType && declarationType !== errorType &&
26840
26840
!isTypeIdenticalTo(type, declarationType) &&
26841
26841
!(symbol.flags & SymbolFlags.Assignment)) {
26842
- errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType);
26842
+ errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
26843
26843
}
26844
26844
if (node.initializer) {
26845
26845
checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined);
@@ -26859,17 +26859,24 @@ namespace ts {
26859
26859
}
26860
26860
}
26861
26861
26862
- function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType: Type, nextDeclaration: Declaration, nextType: Type): void {
26862
+ function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration: Declaration | undefined, firstType: Type, nextDeclaration: Declaration, nextType: Type): void {
26863
26863
const nextDeclarationName = getNameOfDeclaration(nextDeclaration);
26864
26864
const message = nextDeclaration.kind === SyntaxKind.PropertyDeclaration || nextDeclaration.kind === SyntaxKind.PropertySignature
26865
26865
? Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
26866
26866
: Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
26867
- error(
26867
+ const declName = declarationNameToString(nextDeclarationName);
26868
+ const err = error(
26868
26869
nextDeclarationName,
26869
26870
message,
26870
- declarationNameToString(nextDeclarationName) ,
26871
+ declName ,
26871
26872
typeToString(firstType),
26872
- typeToString(nextType));
26873
+ typeToString(nextType)
26874
+ );
26875
+ if (firstDeclaration) {
26876
+ addRelatedInfo(err,
26877
+ createDiagnosticForNode(firstDeclaration, Diagnostics._0_was_also_declared_here, declName)
26878
+ );
26879
+ }
26873
26880
}
26874
26881
26875
26882
function areDeclarationFlagsIdentical(left: Declaration, right: Declaration) {
0 commit comments