resize-observer-polyfill icon indicating copy to clipboard operation
resize-observer-polyfill copied to clipboard

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

Open wendellestradairely opened this issue 3 years ago • 18 comments

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 avatar Jan 24 '21 15:01 wendellestradairely

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

wendellestradairely avatar Jan 24 '21 15:01 wendellestradairely

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

alecgibson avatar Feb 24 '21 08:02 alecgibson

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

alecgibson avatar Feb 24 '21 17:02 alecgibson

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

grosch avatar Feb 24 '21 21:02 grosch

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?

alecgibson avatar Feb 25 '21 07:02 alecgibson

Is there any ETA on this getting officially fixed?

grosch avatar Mar 04 '21 23:03 grosch

When this fix will be merged into master?

juzeppe9000 avatar Mar 10 '21 08:03 juzeppe9000

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.

HristoP96 avatar Apr 26 '21 14:04 HristoP96

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

deefour avatar Apr 28 '21 17:04 deefour

@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

BenLune avatar May 14 '21 20:05 BenLune

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

AruljothySundaramoorthy avatar May 21 '21 17:05 AruljothySundaramoorthy

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

CarlosAmaral avatar May 24 '21 07:05 CarlosAmaral

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

viktor-berezin avatar May 27 '21 21:05 viktor-berezin

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

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

Sina7312 avatar May 31 '21 04:05 Sina7312

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

thank you.worked for me.

shirisha-96 avatar Jun 22 '21 06:06 shirisha-96

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

fotsohilaire avatar Jul 09 '21 10:07 fotsohilaire

image

By using this method i can run my application now.

AruljothySundaramoorthy avatar Jul 18 '21 19:07 AruljothySundaramoorthy

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.

seremwen avatar Feb 08 '23 16:02 seremwen