Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

'ClientRect' is deprecated

I’m working on some old TypeScript projects made by someone else and they used ClientRect like this:

type CallbackFn = (rect: ClientRect) => void;

TypeScript is saying that ‘ClientRect’ is deprecated. What is the alternative?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

ClientRect inherits from DOMRect, so you can use DOMRect.

/** @deprecated */
interface ClientRect extends DOMRect {
}

DOMRect:

/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMRect) */
interface DOMRect extends DOMRectReadOnly {
    height: number;
    width: number;
    x: number;
    y: number;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading