perf(compiler-cli): optimize missing directive extended checks

Extended diagnostics for `missingStructuralDirective` and
`missingControlFlowDirective` previously queried `getSymbolOfNode()` to
determine whether any directives matched a template node.
This caused the template type checker to lazily generate and traverse the
full Type Check Block (TCB) AST and symbol graph for every template node
checked, introducing noticeable build time overhead in large applications
with many components and structural directives.

(cherry picked from commit b9f7c1fe82)
This commit is contained in:
Alan Agius
2026-10-07 13:56:49 +00:00
committed by Kirill Cherkashin
parent 54d134b6c1
commit f43c63f70c
2 changed files with 4 additions and 4 deletions
@@ -72,8 +72,8 @@ class MissingControlFlowDirectiveCheck extends TemplateCheckWithVisitor<ErrorCod
);
if (!controlFlowAttr) return [];
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
if (symbol === null || symbol.directives.length > 0) {
const directives = ctx.templateTypeChecker.getDirectivesOfNode(component, node);
if (directives?.length) {
return [];
}
@@ -71,11 +71,11 @@ class MissingStructuralDirectiveCheck extends TemplateCheckWithVisitor<ErrorCode
);
if (!customStructuralDirective) return [];
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
const directives = ctx.templateTypeChecker.getDirectivesOfNode(component, node);
// Check if there's a directive that matches the structural directive we're checking.
// The structural directive *foo desugars to [foo], so we need to check if any
// directive's selector would match the attribute [foo].
const hasStructuralDirective = symbol?.directives.some((dir) =>
const hasStructuralDirective = directives?.some((dir) =>
dir.selector?.includes(`[${customStructuralDirective.name}]`),
);
if (hasStructuralDirective) return [];