Skip to content

Add getBoundingClientRect to EventTarget typeΒ #61836

Closed as not planned
Closed as not planned
@trollepierre

Description

@trollepierre

πŸ”Ž Search Terms

"getBoundingClientRect"

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

No response

πŸ’» Code

onClick: (event: MouseEvent): void => {
  const { left, top } = event.target.getBoundingClientRect();
  const { left, top } = event.nativeEvent.target.getBoundingClientRect();
},

πŸ™ Actual behavior

Hi.
I've found that I can't use getBoundingClientRect with MouseEvent in typescript.

onClick: (event: MouseEvent): void => {
  const { left, top } = event.target.getBoundingClientRect();
  const { left, top } = event.nativeEvent.target.getBoundingClientRect();
},

Typescript message I see in VS code is:

Property 'getBoundingClientRect' does not exist on type 'EventTarget'.ts(2339)

πŸ™‚ Expected behavior

No typescript message

Additional information about the issue

facebook/react#16201

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions