I am trying to extend puppeteer's class ElementHandle with one method. I have checked some examples and wrote simple code just like in this answer.
But VSCode shows me an error for the line where I change ElementHandle prototype:
'ElementHandle' only refers to a type, but is being used as a value here.ts(2693)
How can I fix it?
My code:
import { ElementHandle } from 'puppeteer';
declare module 'puppeteer' {
interface ElementHandle {
scrollIntoView(): void;
}
}
ElementHandle.prototype.scrollIntoView = async function (): Promise<void> {
await this._scrollIntoViewIfNeeded();
}
ElementHandle class: https://github.com/puppeteer/puppeteer/blob/master/src/JSHandle.js