5

我试图strictNullChecks在 Angular 4 应用程序中实现。

我刚刚添加 "strictNullChecks": truetsconfig.json

当我运行应用程序时ng serve,出现以下错误。

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.

怎么了?我们如何strictNullChecks在 Angular 4 中实现?

4

1 回答 1

6

角度 2.x-4x

当您启用strictNullChecks时,它会为所有 TypeScript 文件启用它,其中包括库。

strictNullChecks在 Angular CLI 项目中启用,skipLibCheck请在 tsConfig 中设置为 true。

Angular 5.x+ 已经解决了这个问题。

于 2017-12-04T18:36:02.167 回答