I have been attempting to implement a function that triggers when the user reaches the bottom of the window, but TypeScript is flagging errors and mentioning potential undefined objects related to window.scrollTop(), height(), and document.height().
Even after incorporating an if statement to handle cases where the object might be undefined, I am still encountering issues.
mounted() {
// Unable to proceed due to potential undefined object
$(window).scroll(() => {
if (
$(window).scrollTop() + $(window).height() >
$(document).height() - 100
) {
console.log(this.lastCursor);
}
});
},