Skip to content

Inconsistents with ClientRect definition #11085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HolgerJeromin opened this issue Sep 23, 2016 · 5 comments
Closed

Inconsistents with ClientRect definition #11085

HolgerJeromin opened this issue Sep 23, 2016 · 5 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this

Comments

@HolgerJeromin
Copy link
Contributor

HolgerJeromin commented Sep 23, 2016

TypeScript Version: 2.0.3

Typescript 2.0.3 has a lot of readonly stuff in lib.d.ts.

I am surprised that only height and width is readonly in ClientRect definition.

interface ClientRect {
    bottom: number;
    readonly height: number;
    left: number;
    right: number;
    top: number;
    readonly width: number;
}

Is this an error?
Mozillas response of getBoundingClientRect is the other way round:
all but height/width readonly (if i can trust FireBug) and has added x, y

Sidenote: ClientRect has been renamed to DOMRect

@mhegazy mhegazy added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this labels Dec 16, 2016
@mhegazy mhegazy added this to the Community milestone Dec 16, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Dec 16, 2016

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

@thitemple
Copy link

I'd be willing to do this. It seems pretty straightforward. If I understand the spec correctly, there are two properties missing x and y.

X, Y, width and height should not be readonly and the others should.

Also, about the name, which is now DOMRect, should I rename it? Or should I just create a new interface and make one inherit from the other?

@muj-beg
Copy link

muj-beg commented Sep 27, 2017

Pull request: microsoft/TypeScript-DOM-lib-generator#299

@hackhat
Copy link

hackhat commented Sep 11, 2018

getBoundingClientRect().x gives me Error:(19, 30) TS2339: Property 'x' does not exist on type 'ClientRect | DOMRect'. Property 'x' does not exist on type 'ClientRect'.

How come has not been fixed yet?

@HolgerJeromin
Copy link
Contributor Author

To be backward compatible getBoundingClientRect returns the old and new interface:

let unspecifiedRect = document.body.getBoundingClientRect();
unspecifiedRect.x // fails
let domRect = document.body.getBoundingClientRect() as DOMRect;
domRect.x       // works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

5 participants