resize-observer-polyfill: Error when compiling: Property 'contentRect' must be of type 'DOMRectReadOnly'

Compiling TypeScript sources through NGC
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;
                    ~~~~~~~~~~~

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 67
  • Comments: 18

Commits related to this issue

Most upvoted comments

Guys there is fix for this “skipLibCheck”: true," in your tsconfig.json and recompile the applicaiton

When this fix will be merged into master?

image

By using this method i can run my application now.

You can try adding “skipLibCheck” option in tsconfig.json if the underlying libraries are using it

https://www.typescriptlang.org/tsconfig#skipLibCheck

I guess a resolution for this issue is to change the resize observer. We switched it with @juggle/resize-observer with small additional changes and this resolved the issue.

The issue is because the latest version of TypeScript ships with an official type definition, which this library conflicts with.

We’ve quick-fixed it by just using:

const ResizeObserverPolyfill = require('resize-observer-polyfill');

const observer: ResizeObserver = new ResizeObserverPolyfill();

But that obviously only works if you have a direct dependency on it.

I guess you’d have to reach out to whichever library is using it, and ask them to do something about it?

We don’t have @types/resize-observer-browser installed, but also get this issue.

@HristoP96 thank you too ! Just had the problem after switching to angular 12 using typescript 4.2.4. I’ll give a try to @juggle/resize-observer

bonsoir l équipe j ai eu le même problème que faire

@BenLune any luck? have the same issue when upgrading to Angular 12.

Angular 12 supports and actually requires typescript 4.2. As option you can just remove resize-observer-polyfill module at all. You can use ResizeObserver definition exactly from typescript package.

@BenLune any luck? have the same issue when upgrading to Angular 12.

Is there any ETA on this getting officially fixed?

I think this happens when “@types/resize-observer-browser” is also installed.