Try tracking deferred nodes using 2 arrays: one to maintain order, the other as a simple sparse array.
This commit is contained in:
Родитель
3c0a3e536c
Коммит
ab686d83e9
|
@ -44345,15 +44345,26 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const enclosingFile = getSourceFileOfNode(node);
|
||||
const links = getNodeLinks(enclosingFile);
|
||||
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
|
||||
links.deferredNodes ||= new Set();
|
||||
links.deferredNodes.add(node);
|
||||
links.deferredNodes ??= {
|
||||
order: [],
|
||||
set: [],
|
||||
};
|
||||
const { order, set } = links.deferredNodes;
|
||||
const nodeId = getNodeId(node);
|
||||
if (set[nodeId] === undefined) {
|
||||
order.push(nodeId);
|
||||
set[nodeId] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkDeferredNodes(context: SourceFile) {
|
||||
const links = getNodeLinks(context);
|
||||
if (links.deferredNodes) {
|
||||
links.deferredNodes.forEach(checkDeferredNode);
|
||||
const { order, set } = links.deferredNodes;
|
||||
for (const nodeId of order) {
|
||||
checkDeferredNode(set[nodeId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5975,7 +5975,7 @@ export interface NodeLinks {
|
|||
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
|
||||
jsxImplicitImportContainer?: Symbol | false; // Resolved module symbol the implicit jsx import of this file should refer to
|
||||
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
|
||||
deferredNodes?: Set<Node>; // Set of nodes whose checking has been deferred
|
||||
deferredNodes?: { order: number[]; set: Record<number, Node> }; // Set of nodes whose checking has been deferred
|
||||
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
|
||||
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
|
||||
isExhaustive?: boolean | 0; // Is node an exhaustive switch statement (0 indicates in-process resolution)
|
||||
|
|
Загрузка…
Ссылка в новой задаче