I am trying to add a method for when the user gets to the bottom of the window, but typescript is stopping me and saying the object is possibly undefined on window.scrollTop(), height(), and document.height().
I've already tried putting an if statement beforehand and only running the code if it is defined, but I keep getting the error.
mounted() {
// Does not work because object might be undefined
$(window).scroll(() => {
if (
$(window).scrollTop() + $(window).height() >
$(document).height() - 100
) {
console.log(this.lastCursor);
}
});
},