question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript viewport event handler does not exist

See original GitHub issue

Hello, I’m trying to add an event handler to a viewport like so const viewport = new Viewport().on("clicked", () => {}); But I’m getting the Typescript error Property 'on' does not exist on type 'Viewport'.

Is this method missing from the Viewport’s Typescript definition? Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
matthewbordascommented, Nov 16, 2021

Ahh ok so the project was on an older version. It’s now fixed after upgrading from v5.3.3 -> v6.2.0. Thanks so much for the help!

1reaction
Rekkyncommented, Sep 28, 2021

Turns out the problem was not having "esModuleInterop": true in my tsconfig.json file. Adding that fixed the type error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'addEventListener' of null - Stack Overflow
I think the easiest approach would be to just check that el is not null before adding an event listener: var el =...
Read more >
VisualViewport: scroll event - Web APIs - MDN Web Docs
The scroll event of the VisualViewport interface is fired when the visual viewport is scrolled.
Read more >
Scroll Events and Intersection Observer - Beginner JavaScript
In this video we will learn about scroll events. A scroll event is when someone goes ahead and scrolls on the page or...
Read more >
ResizeObserver: it's like document.onresize for elements
ResizeObserver notifies you when an element's content rectangle changes size so that you can react accordingly.
Read more >
mouseup and mousedown event types missing? #289 - GitHub
Edit: Hmm, maybe I'm mistaken here. I tried downgrading again but the errors are still there. Might be the fact that I upgraded...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found