From f43c63f70cfd3cd407807e50ea309d142dfd8c73 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 7 Oct 2026 15:56:45 +0200 Subject: [PATCH] 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 b9f7c1fe827e1fe79499a051e9f3722aa9c23dde) --- .../extended/checks/missing_control_flow_directive/index.ts | 4 ++-- .../extended/checks/missing_structural_directive/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_control_flow_directive/index.ts b/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_control_flow_directive/index.ts index a8ab036ab95..14e3c0ff324 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_control_flow_directive/index.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_control_flow_directive/index.ts @@ -72,8 +72,8 @@ class MissingControlFlowDirectiveCheck extends TemplateCheckWithVisitor 0) { + const directives = ctx.templateTypeChecker.getDirectivesOfNode(component, node); + if (directives?.length) { return []; } diff --git a/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_structural_directive/index.ts b/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_structural_directive/index.ts index 062183b36ab..bf3e53c19db 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_structural_directive/index.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_structural_directive/index.ts @@ -71,11 +71,11 @@ class MissingStructuralDirectiveCheck extends TemplateCheckWithVisitor + const hasStructuralDirective = directives?.some((dir) => dir.selector?.includes(`[${customStructuralDirective.name}]`), ); if (hasStructuralDirective) return [];