resize-observer-polyfill
resize-observer-polyfill copied to clipboard
DOMRectReadOnly interface type miss toJSON() method
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.
would be great to also export your version of DOMRectReadOnly.
I second this. https://github.com/microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L4133
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.