@@ -8679,15 +8679,28 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
8679
8679
else {
8680
8680
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
8681
8681
}
8682
- if (isIdentifier(node)) {
8683
- const type = getDeclaredTypeOfSymbol(sym);
8684
- const name = sym.flags & SymbolFlags.TypeParameter ? typeParameterToName(type, context) : factory.cloneNode(node);
8685
- name.symbol = sym; // for quickinfo, which uses identifier symbol information
8686
- return { introducesError, node: setTextRange(setEmitFlags(setOriginalNode(name, node), EmitFlags.NoAsciiEscaping), node) };
8687
- }
8682
+ return { introducesError, node: attachSymbolToLeftmostIdentifier(node) as T };
8688
8683
}
8689
8684
8690
8685
return { introducesError, node };
8686
+
8687
+ /**
8688
+ * Attaches a `.symbol` member to an identifier, cloning it to do so, so symbol information
8689
+ * is smuggled out for symbol display information.
8690
+ */
8691
+ function attachSymbolToLeftmostIdentifier(node: Node): Node {
8692
+ if (node === leftmost) {
8693
+ const type = getDeclaredTypeOfSymbol(sym!);
8694
+ const name = sym!.flags & SymbolFlags.TypeParameter ? typeParameterToName(type, context) : factory.cloneNode(node as Identifier);
8695
+ name.symbol = sym!; // for quickinfo, which uses identifier symbol information
8696
+ return setTextRange(setEmitFlags(setOriginalNode(name, node), EmitFlags.NoAsciiEscaping), node);
8697
+ }
8698
+ const updated = visitEachChild(node, c => attachSymbolToLeftmostIdentifier(c), /*context*/ undefined);
8699
+ if (updated !== node) {
8700
+ setTextRange(updated, node);
8701
+ }
8702
+ return updated;
8703
+ }
8691
8704
}
8692
8705
8693
8706
/**
@@ -8856,11 +8869,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
8856
8869
}
8857
8870
8858
8871
if (isEntityName(node) || isEntityNameExpression(node)) {
8872
+ if (isDeclarationName(node)) {
8873
+ return node;
8874
+ }
8859
8875
const { introducesError, node: result } = trackExistingEntityName(node, context);
8860
8876
hadError = hadError || introducesError;
8861
- if (result !== node) {
8862
- return result;
8863
- }
8877
+ // We should not go to child nodes of the entity name, they will not be accessible
8878
+ return result;
8864
8879
}
8865
8880
8866
8881
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
0 commit comments