Search code examples
typescripttsconfigts-loader

typescript error TS2531 Object is possibly 'null' is NOT being suppressed by strictNullChecks : false


My typescript compile is throwing the following error

TS2531: Object is possibly 'null'.

I am converting code with an insane number of these errors and just want to suppress them to finish getting the build working. It was my understanding that adding the following in my tsconfig.json file would suppress this error.

"compilerOptions": { "strictNullChecks": false}

However the error still shows. I cannot find any other compilerOption specific to this error. Is there an option to suppress it?


Solution

  • I think you are not properly initializing some variables. You either can add a definite Assignment declaration with a ! or turn off the rule entirely. If this does not help some examples of failing code would be nice :)

    To turn off add the folowing rule

    "strictPropertyInitialization": false

    {
      "compilerOptions": {
        "strict": false,
        "strictPropertyInitialization": false,
        "strictNullChecks": false,
      }
    }