angulartypescriptstrictnullchecks

How to implement strictNullChecks in angular 4


I have tried to implement strictNullChecks in angular 4 application.

I have just added "strictNullChecks": true in tsconfig.json

When I run the application ng serve I got this below error.

ERROR in [at-loader] ./node_modules/@angular/forms/src/model.d.ts:244:39 
TS2459: Type '{ onlySelf?: boolean | undefined; emitEvent?: boolean | 
undefined; } | undefined' has no property 'emitEvent' and no string index signature.

What's going wrong? How can we implement strictNullChecks in angular 4?


Solution

  • Angular 2.x-4x

    When you enable strictNullChecks, it enables it for all TypeScript files, which includes libraries.

    To enable strictNullChecks in an Angular CLI project set skipLibCheck to true in your tsConfig.

    Angular 5.x+ has addressed this issue.