Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

Angular Compiler Options: Where to Set Them and Which Ones to Use

Configure Angular compiler options in angularCompilerOptions, understand AOT and compilation modes, and choose useful template checks without confusing them with CLI build settings.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set Angular compiler options in the angularCompilerOptions object of a TypeScript configuration file such as tsconfig.json. Keep them separate from TypeScript’s compilerOptions and from Angular CLI build settings in angular.json. For most applications, start with the defaults, enable strict template checking, and use full compilation; choose partial compilation when publishing a library for consumers on different Angular versions.

Where Angular compiler options belong

Angular’s compiler-options reference says the Angular compiler is primarily configured through tsconfig.json, while Angular CLI is primarily configured through angular.json. In a TypeScript configuration file, put Angular-specific settings at the top level under angularCompilerOptions, alongside (not inside) TypeScript’s compilerOptions.

As an Amazon Associate I earn from qualifying purchases.

{
  "compilerOptions": {
    "strict": true
  },
  "angularCompilerOptions": {
    "strictTemplates": true,
    "strictInjectionParameters": true
  }
}

See the Angular compiler options reference for supported settings. A configuration can extend another one: the base configuration loads first, and the extending file can override it. This lets a workspace keep shared settings in tsconfig.json while an application-specific file such as tsconfig.app.json supplies or overrides settings for that application. Angular’s file-structure guide describes the role of the workspace’s TypeScript configuration files.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compiler options versus CLI build settings

Options that control Angular template compilation belong in angularCompilerOptions. Build and workspace behavior belongs in Angular CLI configuration. For example, ng build documents an aot boolean option, with a default of true; workspace optimization settings cover such output steps as minification, tree-shaking, dead-code elimination, critical CSS, and font inlining. See the ng build reference and workspace configuration guide. The exact options and defaults depend on Angular version and builder, so check those used by your project.

AOT or JIT: which compilation model applies?

With ahead-of-time (AOT) compilation, Angular compiles templates and TypeScript during the build. Just-in-time (JIT) compilation instead compiles in the browser at runtime. Angular’s AOT guide describes AOT’s benefits as faster rendering, fewer asynchronous requests, a smaller framework download because the compiler need not be downloaded, earlier template-error detection, and fewer opportunities for injection attacks. These are the guide’s stated reasons for using AOT, not guarantees of a particular measured improvement in every application.

The guide says AOT has been the default starting with Angular 9, and the current CLI build reference lists aot as true by default. Confirm the effective setting in your project’s version, builder, and configuration rather than assuming a default has not been overridden. Most users invoke the compiler through Angular CLI; the Angular compiler can also be invoked through ngc from @angular/compiler-cli.

Full or partial compilation?

The compilationMode setting affects the form of compiled output. Choose according to whether you are building an application for its own Angular version or packaging a library for use by other projects.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Mode Best fit Why
full Most applications; also libraries built in a monorepo with an app using the same Angular version Produces code for the Angular version currently in use. It is the normal choice when the consuming application uses that version.
partial Independently published libraries Emits a stable intermediate form suited to consumers using a different Angular version, reducing version-skew concerns.

These uses are described in the compiler-options reference and Angular’s Angular Package Format guide. Partial compilation is not a general-purpose optimization switch for application builds; its value is compatibility for library distribution.

Should you enable strict template and injection checks?

strictTemplates

strictTemplates enables strict type checking for Angular templates. Angular’s AOT guide explains that template checking uses TypeScript to validate bindings and surface errors during the build, before they can become runtime problems. The compiler-options reference lists strict template checking as enabled by default. Check your effective configuration before changing it, especially in an existing project where an extending TypeScript config may override the setting.

The Angular Language Service reads tsconfig.json and provides template completions, errors, hints, and navigation in the editor. Its guide recommends strictTemplates: true for the latest language-service features.

strictInjectionParameters

This option checks whether Angular can determine the types of dependency-injection parameters. The compiler-options reference recommends setting it to true, although it identifies false as the default. Enabling it can reveal parameters whose types Angular cannot infer; address the resulting type or provider issues rather than disabling the check without understanding the cause.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Other compiler settings worth changing only for a reason

  • annotationsAs: The default is static fields, which the reference says can help advanced tree-shakers remove unused classes. Setting it to decorators can make compilation faster but may inhibit tree-shaking.
  • enableI18nLegacyMessageIdFormat: The documented default is true. Angular recommends false unless the project relies on translations created with legacy message IDs. Support differs by builder, so verify compatibility before changing it.
  • preserveWhitespaces: The default is false. Angular recommends keeping that default for hydration and notes that preserving whitespace is not yet fully supported for hydration. If you enable it, keep server and client configurations consistent.
  • disableTypeScriptVersionCheck: This suppresses errors for unsupported TypeScript versions. Angular does not recommend using it: unsupported versions may produce undefined behavior.

Options such as flatModuleOutFile, skipMetadataEmit, skipTemplateCodegen, and strictMetadataEmit concern library packaging or legacy metadata output. Treat them as library-specific settings, not routine additions to an application’s configuration.

How to make a safe configuration change

  1. Identify the TypeScript configuration file actually used by the target build, and check its extends chain for inherited settings and overrides.
  2. Put Angular template/compiler settings under angularCompilerOptions; change CLI build settings in the workspace/build configuration instead.
  3. Choose options for the project’s purpose: full compilation for most apps, partial compilation for independently published libraries, and strict checks when you want earlier diagnostics.
  4. Build with the project’s normal Angular CLI command and review compiler errors. If a setting is unsupported or behaves differently, check the documentation for the installed Angular version and builder.

Angular’s compiler settings and defaults can change across releases. The current official references explain the configuration model, but the project’s installed Angular version and builder determine what is available and effective.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.