解决Angular12报错(resize-observer-polyfill) TS2717:Property contentRect must be of type DOMRectReadOnly
升级到Angular 12后,Angular UI 组件库 ng-zorro-antd 引用的 resize-observer-polyfill 库报错: Property contentRect must be of type DOMRectReadOnly, but here has type DOMRectReadOnly
具体报错如下:
$ ng serve
Error: node_modules/resize-observer-polyfill/src/index.d.ts:19:18 - error TS2717:
Subsequent property declarations must have the same type.
Property 'contentRect' must be of type 'DOMRectReadOnly', but here has type 'DOMRectReadOnly'.
19 readonly contentRect: DOMRectReadOnly;
~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:12696:14
12696 readonly contentRect: DOMRectReadOnly;
~~~~~~~~~~~
'contentRect' was also declared here.
(1) 由于报错的是第三方类库,只能等待第三方类库去修复该错误。
(2) 在第三方修复之前,可以禁用第三方类库的检查。
在项目根目录的 TS 配置文件 tsconfig.json
中新增 skipLibCheck
属性。
{
"compilerOptions": {
。。。。。。
"skipLibCheck": true <---- 增加该配置
}
}
https://github.com/NG-ZORRO/ng-zorro-antd/issues/6696
https://www.typescriptlang.org/tsconfig#skipLibCheck