que-etc / resize-observer-polyfill

A polyfill for the Resize Observer API
MIT License
1.75k stars 132 forks source link

Error when compiling: Property 'contentRect' must be of type 'DOMRectReadOnly' #80

Open wendellestradairely opened 3 years ago

wendellestradairely commented 3 years ago
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;
                    ~~~~~~~~~~~
wendellestradairely commented 3 years ago

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

alecgibson commented 3 years ago

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

alecgibson commented 3 years ago

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

grosch commented 3 years ago

How do we resolve? I'm getting this package because another one I install depends on it.

alecgibson commented 3 years ago

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?

grosch commented 3 years ago

Is there any ETA on this getting officially fixed?

juzeppe9000 commented 3 years ago

When this fix will be merged into master?

HristoP96 commented 3 years ago

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.

deefour commented 3 years ago

@HristoP96 thank you for pointing this out!! :fist_oncoming:

BenLune commented 3 years ago

@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

AruljothySundaramoorthy commented 3 years ago

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

CarlosAmaral commented 3 years ago

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

viktor-berezin commented 3 years ago

@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.

Sina7312 commented 3 years ago

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

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

shirisha-96 commented 3 years ago

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

thank you.worked for me.

fotsohilaire commented 3 years ago

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

AruljothySundaramoorthy commented 3 years ago

image

By using this method i can run my application now.

seremwen commented 1 year ago

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

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

Thhank you. This worked for me.