Turning off Strict Mode in Angular?

Tags: , , , ,



I’m running into this issue and I’d like to turn off strict mode to get around it.

I’ve modified tsconfig.json with:

"compilerOptions": {
  "strict": false,

And also tried:

 "compilerOptions": {
   "noImplicitUseStrict": true,

But no love. Thoughts?

Answer

If anybody runs into this question, I had a similar issue after upgrading from Angular 8 to Angular 10. I had to remove all angular compiler flags, and used the following TS flags:

On tsconfig.json:

  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "experimentalDecorators": true,
    "module": "es2020",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "noImplicitUseStrict": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }

On angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "my-project-name": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:application": {
          "strict": false
        }
      }
    }
  }
}


Source: stackoverflow