mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Reduce polymorphism resulting from unstable Node shapes (#51682)
* Move .symbol to Declaration * simplify some factories * Move localSymbol to Declaration * Ensure JSDocContainer types are properly initialized * Move contextualType from Node to NodeLinks * Move 'locals' and 'nextContainer' out of Node * Move 'flowNode' out of 'Node' * Pre-define endFlowNode/returnFlowNode * Pre-define some SourceFile properties and a more stable cloneNode * Don't add excess properties to type nodes in typeToTypeNode * Refactor wrapSymbolTrackerToReportForContext to improve perf
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
Block,
|
||||
BreakOrContinueStatement,
|
||||
CancellationToken,
|
||||
canHaveSymbol,
|
||||
CaseClause,
|
||||
cast,
|
||||
concatenate,
|
||||
@@ -78,6 +79,7 @@ import {
|
||||
ThrowStatement,
|
||||
toArray,
|
||||
toPath,
|
||||
tryCast,
|
||||
TryStatement,
|
||||
} from "./_namespaces/ts";
|
||||
|
||||
@@ -184,7 +186,7 @@ export namespace DocumentHighlights {
|
||||
}
|
||||
|
||||
function getFromAllDeclarations<T extends Node>(nodeTest: (node: Node) => node is T, keywords: readonly SyntaxKind[]): HighlightSpan[] | undefined {
|
||||
return useParent(node.parent, nodeTest, decl => mapDefined(decl.symbol.declarations, d =>
|
||||
return useParent(node.parent, nodeTest, decl => mapDefined(tryCast(decl, canHaveSymbol)?.symbol.declarations, d =>
|
||||
nodeTest(d) ? find(d.getChildren(sourceFile), c => contains(keywords, c.kind)) : undefined));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user