mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
Skip visits to child nodes of entity names in visitExistingNodeTreeSymbols (#58067)
This commit is contained in:
parent
772c29072e
commit
83e3d6ae59
@ -8679,15 +8679,28 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
else {
|
||||
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
||||
}
|
||||
if (isIdentifier(node)) {
|
||||
const type = getDeclaredTypeOfSymbol(sym);
|
||||
const name = sym.flags & SymbolFlags.TypeParameter ? typeParameterToName(type, context) : factory.cloneNode(node);
|
||||
name.symbol = sym; // for quickinfo, which uses identifier symbol information
|
||||
return { introducesError, node: setTextRange(setEmitFlags(setOriginalNode(name, node), EmitFlags.NoAsciiEscaping), node) };
|
||||
}
|
||||
return { introducesError, node: attachSymbolToLeftmostIdentifier(node) as T };
|
||||
}
|
||||
|
||||
return { introducesError, node };
|
||||
|
||||
/**
|
||||
* Attaches a `.symbol` member to an identifier, cloning it to do so, so symbol information
|
||||
* is smuggled out for symbol display information.
|
||||
*/
|
||||
function attachSymbolToLeftmostIdentifier(node: Node): Node {
|
||||
if (node === leftmost) {
|
||||
const type = getDeclaredTypeOfSymbol(sym!);
|
||||
const name = sym!.flags & SymbolFlags.TypeParameter ? typeParameterToName(type, context) : factory.cloneNode(node as Identifier);
|
||||
name.symbol = sym!; // for quickinfo, which uses identifier symbol information
|
||||
return setTextRange(setEmitFlags(setOriginalNode(name, node), EmitFlags.NoAsciiEscaping), node);
|
||||
}
|
||||
const updated = visitEachChild(node, c => attachSymbolToLeftmostIdentifier(c), /*context*/ undefined);
|
||||
if (updated !== node) {
|
||||
setTextRange(updated, node);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -8856,11 +8869,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
if (isEntityName(node) || isEntityNameExpression(node)) {
|
||||
if (isDeclarationName(node)) {
|
||||
return node;
|
||||
}
|
||||
const { introducesError, node: result } = trackExistingEntityName(node, context);
|
||||
hadError = hadError || introducesError;
|
||||
if (result !== node) {
|
||||
return result;
|
||||
}
|
||||
// We should not go to child nodes of the entity name, they will not be accessible
|
||||
return result;
|
||||
}
|
||||
|
||||
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user