如何在角度4中实现strictNullChecks

Ram*_*ran 4 typescript angular strictnullchecks

我试图strictNullChecks在角度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.
Run Code Online (Sandbox Code Playgroud)

出了什么问题?我们怎样才能strictNullChecks在角4中实现?

cga*_*ian 6

角度2.x-4x

启用时strictNullChecks,它会为包含库的所有TypeScript文件启用它.

strictNullChecksskipLibCheckAngCon CLI项目中启用,请在tsConfig中设置为true.

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