Nx: Angular Strict Mode Support

Created on 22 Jul 2020  路  1Comment  路  Source: nrwl/nx

Description


When generating a new application using the Angular CLI we can pass --strict flag to turn on strict template type checking and strict TypeScript checking.

It would be good to have this option available when using the Nx Angular Application and Library schematics too.

For example, this would add the following in an Angular CLI application:

tsconfig.base.json

/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": true, // enable strict type checking
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "module": "es2020",
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": { // Add strict template checks
    "strictInjectionParameters": true,
    "strictTemplates": true
  }
}

Motivation


Stricter type safety can be very useful especially in large enterprise applications. It would also be good to have parity with the @angular/cli generate schematic for this feature.

Suggested Implementation

ng generate @nrwl/angular:application my-app --strict

Alternate Implementations


Library support as well perhaps?

ng generate @nrwl/angular:library my-lib --strict

Thanks 馃槉

angular feature

Most helpful comment

It would be great if it were also possible to execute create-nx-workspace with a strict flag

>All comments

It would be great if it were also possible to execute create-nx-workspace with a strict flag

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markphip picture markphip  路  3Comments

zachnewburgh picture zachnewburgh  路  3Comments

danieldanielecki picture danieldanielecki  路  3Comments

jasedwards picture jasedwards  路  3Comments

ZempTime picture ZempTime  路  3Comments