Configurations

Angular compiler options

When you use ahead-of-time compilation (AOT), you can control how your application is compiled by specifying Angular compiler options in the TypeScript configuration file.

The Angular options object, angularCompilerOptions, is a sibling to the compilerOptions object that supplies standard options to the TypeScript compiler.

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    // ...
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    // ...
  }
}

Configuration inheritance with extends

Like the TypeScript compiler, the Angular AOT compiler also supports extends in the angularCompilerOptions section of the TypeScript configuration file. The extends property is at the top level, parallel to compilerOptions and angularCompilerOptions.

A TypeScript configuration can inherit settings from another file using the extends property. The configuration options from the base file are loaded first, then overridden by those in the inheriting configuration file.

For example:

tsconfig.app.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    // ...
  },
  // ...
  "angularCompilerOptions": {
    "preserveWhitespaces": true,
    // ...
  }
}

For more information, see the TypeScript Handbook.

Template options

The following options are available for configuring the Angular AOT compiler.

annotationsAs

Modifies how Angular-specific annotations are emitted to improve tree-shaking. Non-Angular annotations are not affected. One of static fields or decorators. The default value is