如何在 angular 4 中实现 strictNullChecks
How to implement strictNullChecks in angular 4
我已经尝试在 angular 4 应用程序中实现 strictNullChecks
。
我刚刚在 tsconfig.json
中添加了 "strictNullChecks": true
当我 运行 应用程序 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.
What's going wrong? How can we implement strictNullChecks
in angular 4?
Angular 2.x-4x
当您启用 strictNullChecks
时,它会为所有 TypeScript 文件启用它,包括库。
要在 Angular CLI 项目中启用 strictNullChecks
,请在您的 tsConfig 中将 skipLibCheck
设置为 true。
Angular 5.x+ 已解决此问题。
我已经尝试在 angular 4 应用程序中实现 strictNullChecks
。
我刚刚在 tsconfig.json
"strictNullChecks": true
当我 运行 应用程序 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.
What's going wrong? How can we implement
strictNullChecks
in angular 4?
Angular 2.x-4x
当您启用 strictNullChecks
时,它会为所有 TypeScript 文件启用它,包括库。
要在 Angular CLI 项目中启用 strictNullChecks
,请在您的 tsConfig 中将 skipLibCheck
设置为 true。