5

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?

Nilesh Khisadiya
  • 1,560
  • 2
  • 15
  • 27
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
  • 3
    Angular 4.x does not support `strictNullChecks`, so I think you have to wait for Angular 5. See https://github.com/angular/angular/issues/15432 https://github.com/angular/angular/issues/16357 and probably several others. (Note the first linked issue says fixed in 4.1, the second says still not fixed in 4.1 but has been closed as a duplicate of the first) – Duncan Jul 04 '17 at 13:39

1 Answers1

6

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.

cgatian
  • 22,047
  • 9
  • 56
  • 76