Skip to content

refactor(@angular/build): isolate TypeScript diagnostics and AST caching in TypeScriptCompilation - #33953

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:refactor/isolate-compilation-diagnostics
Aug 28, 2026
Merged

refactor(@angular/build): isolate TypeScript diagnostics and AST caching in TypeScriptCompilation#33953
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:refactor/isolate-compilation-diagnostics

Conversation

@clydin

@clydin clydin commented Aug 27, 2026

Copy link
Copy Markdown
Member

Decouple the AngularCompilation base class from TypeScript diagnostic structures and types, and encapsulate TypeScript-specific compilation logic in an intermediate TypeScriptCompilation class.

TypeScriptCompilation extends AngularCompilation to manage the ts.SourceFile AST cache, file invalidation, and TypeScript diagnostic collection and conversion. This allows AngularCompilation.diagnoseFiles to return an empty diagnostics result by default, removing collectDiagnostics, static loadTypescript, and typescript imports from AngularCompilation entirely.

AotCompilation and JitCompilation now extend TypeScriptCompilation, sharing unified AST caching and file invalidation logic, while NoopCompilation and ParallelCompilation no longer require dummy collectDiagnostics stubs. In addition, diagnostics.ts is relocated from tools/esbuild/angular/ into tools/angular/compilation/ so TypeScript diagnostic formatting remains strictly encapsulated within the compilation subsystem.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Angular compilation pipeline by introducing a new abstract TypeScriptCompilation class. This class centralizes TypeScript-specific logic, such as managing and invalidating cached source files and diagnosing files, which simplifies AngularCompilation and reduces duplication in AotCompilation and JitCompilation. Feedback on these changes suggests optimizing the diagnoseFiles method in TypeScriptCompilation to return early when modes is set to DiagnosticModes.None, thereby avoiding unnecessary diagnostic collection and profiling overhead.

…ing in TypeScriptCompilation

Decouple the AngularCompilation base class from TypeScript diagnostic structures and types, and encapsulate TypeScript-specific compilation logic in an intermediate TypeScriptCompilation class.

TypeScriptCompilation extends AngularCompilation to manage the ts.SourceFile AST cache, file invalidation, and TypeScript diagnostic collection and conversion. This allows AngularCompilation.diagnoseFiles to return an empty diagnostics result by default, removing collectDiagnostics, static loadTypescript, and typescript imports from AngularCompilation entirely.

AotCompilation and JitCompilation now extend TypeScriptCompilation, sharing unified AST caching and file invalidation logic, while NoopCompilation and ParallelCompilation no longer require dummy collectDiagnostics stubs. In addition, diagnostics.ts is relocated from tools/esbuild/angular/ into tools/angular/compilation/ so TypeScript diagnostic formatting remains strictly encapsulated within the compilation subsystem.
@clydin
clydin force-pushed the refactor/isolate-compilation-diagnostics branch from 7260139 to fbc12d5 Compare August 27, 2026 21:04
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 27, 2026
@clydin
clydin requested a review from alan-agius4 August 27, 2026 21:23
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 28, 2026
@alan-agius4
alan-agius4 merged commit f0b045e into angular:main Aug 28, 2026
40 of 41 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the refactor/isolate-compilation-diagnostics branch August 28, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants