I have the following code in typescript :
window.addEventListener('gamepadconnected', (e: GamepadEvent) => { console.log(e.gamepad) });
But I got the following errors :
No overload matches this call.
Overload 1 of 2, '(type: "abort" | "afterprint" | "beforeprint" | "beforeunload" | "blur" | "canplay" | "canplaythrough" | "change" | "click" | "compassneedscalibration" | "contextmenu" | "dblclick" | ... 122 more ... | "unhandledrejection", listener: (this: Window, ev: Event | ... 22 more ... | PromiseRejectionEvent) => any, options?: boolean | ... 1 more ... | undefined): void', gave the following error.
Argument of type '"gamepadconnected"' is not assignable to parameter of type '"abort" | "afterprint" | "beforeprint" | "beforeunload" | "blur" | "canplay" | "canplaythrough" | "change" | "click" | "compassneedscalibration" | "contextmenu" | "dblclick" | ... 122 more ... | "unhandledrejection"'.
Overload 2 of 2, '(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void', gave the following error.
Argument of type '(e: GamepadEvent) => void' is not assignable to parameter of type 'EventListenerOrEventListenerObject'.
Type '(e: GamepadEvent) => void' is not assignable to type 'EventListener'.
Types of parameters 'e' and 'evt' are incompatible.
Property 'gamepad' is missing in type 'Event' but required in type 'GamepadEvent'.ts(2769)
but this should be possible => https://developer.mozilla.org/en-US/docs/Web/API/Window/gamepadconnected_event
Why, Do I have to lose the type and put any ?