Skip to content

perf(@angular/build): skip semantic affected-file walk when type checking is disabled#33585

Open
mattlewis92 wants to merge 1 commit into
angular:mainfrom
mattlewis92:perf/skip-affected-walk-no-typecheck
Open

perf(@angular/build): skip semantic affected-file walk when type checking is disabled#33585
mattlewis92 wants to merge 1 commit into
angular:mainfrom
mattlewis92:perf/skip-affected-walk-no-typecheck

Conversation

@mattlewis92

Copy link
Copy Markdown
Contributor

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

When type checking is disabled (NG_BUILD_TYPE_CHECK=0), the AOT build still ran a full semantic type-check as a side effect of computing the affected-files set, then discarded the result.

useTypeChecking already suppresses the consumption of semantic diagnostics via the compiler-plugin diagnoseFiles mask, but the production -- the findAffectedFiles -> getSemanticDiagnosticsOfNextAffectedFile walk -- was never gated, so disabling type checking still paid for a full semantic pass whose results were never read.

Issue Number: N/A

What is the new behavior?

Our application is so large that we build it in CI with the NG_BUILD_TYPE_CHECK=0 flag set, and run typechecking separately via ngc -p apps/{projectName}/tsconfig.app.json --noEmit as a parallel job

Our CI build times dropped by ~100s after applying this change! Alongside the patch added in #33526 our build times dropped from ~9.5m to ~5.5m 🚀

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@google-cla

google-cla Bot commented Jul 16, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@angular-robot angular-robot Bot added area: performance Issues related to performance area: @angular/build labels Jul 16, 2026
…king is disabled

When type checking is disabled (`NG_BUILD_TYPE_CHECK=0`), the AOT build still
ran a full semantic type-check as a side effect of computing the affected-files
set, then discarded the result.

`useTypeChecking` already suppresses the *consumption* of semantic diagnostics
via the compiler-plugin `diagnoseFiles` mask, but the *production* -- the
`findAffectedFiles` -> `getSemanticDiagnosticsOfNextAffectedFile` walk -- was
never gated, so disabling type checking still paid for a full semantic pass
whose results were never read.

The affected set has three consumers: Angular template diagnostics (behind the
`semantic` flag, already suppressed when type checking is off), the
single-file vs whole-program diagnostics optimization (also diagnostics only),
and the emit gate in `emitAffectedFiles()`. The emit gate only matters in the
slow TypeScript emit path where cross-file types can change a file's JS; in the
isolatedModules fast path emit is per-file/type-erased, so an empty set is safe.

Gate the walk so it only runs when type checking is on OR the slow emit path is
used, and skip it in the (type-check-off + fast-path) combination.

@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 optimizes the AOT compilation process by skipping the semantic 'affected files' walk when type checking is disabled, as its results are only consumed for diagnostics which are already suppressed in that mode. A new end-to-end test has been added to verify that the emitted JavaScript remains byte-for-byte identical when type checking is toggled. I have no feedback to provide as there were no review comments.

@mattlewis92 mattlewis92 force-pushed the perf/skip-affected-walk-no-typecheck branch from 14cae74 to 561d9ec Compare July 16, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/build area: performance Issues related to performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant