Skip to content

Try tracking deferred nodes using arrays #52605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down