Here is a snippet of my Typescript code:
const pasteFn = (e: ClipboardEvent) => {
const { clipboardData } = e;
const text = clipboardData?.getData('text/plain');
console.log(text);
};
window.addEventListener('paste', pasteFn);
I've been searching extensively and trying various examples, but I can't seem to figure out the error message I'm receiving:
No overload matches this call.
Overload 1 of 2, '(type: keyof WindowEventMap, listener: (this: Window, ev: Event | DeviceMotionEvent | DeviceOrientationEvent | GamepadEvent | ... 23 more ... | StorageEvent) => any, options?: boolean | ... 1 more ... | undefined): void', gave the following error.
Argument of type '"paste"' is not assignable to parameter of type 'keyof WindowEventMap'.
Overload 2 of 2, '(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void', gave the following error.
Argument of type '(e: ClipboardEvent) => void' is not assignable to parameter of type 'EventListenerOrEventListenerObject'.
Type '(e: ClipboardEvent) => void' is not assignable to type 'EventListener'.
Types of parameters 'e' and 'evt' are incompatible.
Property 'clipboardData' is missing in type 'Event' but required in type 'ClipboardEvent'.ts(2769)
lib.dom.d.ts(3747, 14): 'clipboardData' is declared here.