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

DOMRectReadOnly interface type miss toJSON() method

Open IlCallo opened this issue 6 years ago • 3 comments
trafficstars

Trying to contentRect property with right type, but native DOMRectReadOnly has a toJSON method that your interface doesn't have, this results into a type mismatch.

IlCallo avatar Mar 15 '19 16:03 IlCallo

would be great to also export your version of DOMRectReadOnly.

xinghul avatar Mar 19 '19 14:03 xinghul

I second this. https://github.com/microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L4133

concatime avatar Jan 13 '20 15:01 concatime

I've got a function that I was trying to pass entry.contentRect to, so for the meantime, I'm just defining the argument as Partial<DOMRectReadOnly> for now.

...

const myFunction = (domRect: Partial<DOMRectReadOnly>) => {/*do something*/}

...

for ( const entry of entries) {
   myFunction(entry.contentRect); //works
}

Argument of type "DOMRectReadOnly" is not assignable to parameter of the type "DOMRectReadOnly"

But yeah, either just having this package use TypeScript's built-in DOMRectReadOnly or exporting the one defined by this package would be nice.

JSXS avatar Apr 17 '20 21:04 JSXS