I'm trying to extend HTMLDivElement prototype with a new method. However, I don't want to pollute the HTMLDivElement itself with my methods so I'm trying to create a new class that extends it.
export class ScrollableElement extends HTMLDivElement {
scrollHorizontal(left: number) {
this.scrollTo({ left, behavior: 'smooth' });
}
}
I use this element for scrollable div's ref. However, whenever I try to call this method, I get error saying listRef.scrollHorizontal is not a function
.
Is there any way to achieve this?