Javascript Can';使用addEventListener时不要使用GamepadEvent

Javascript Can';使用addEventListener时不要使用GamepadEvent,javascript,typescript,gamepad,Javascript,Typescript,Gamepad,我在typescript中有以下代码: window.addEventListener('gamepadconnected',(e:GamepadEvent)=>{ console.log(例如gamepad) }); 但我犯了以下错误: No overload matches this call. Overload 1 of 2, '(type: "abort" | "afterprint" | "beforeprint" | "beforeunload" | "blur" | "canp

我在typescript中有以下代码:

window.addEventListener('gamepadconnected',(e:GamepadEvent)=>{ console.log(例如gamepad) });

但我犯了以下错误:

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)
但这应该是可能的=>


为什么,我必须把字型弄丢,然后再放一个

我不确定为什么键入不正确,但这就是我目前正在做的解决方法:
window.addEventListener('gamepadconnected',(evt)=>{const e=evt as GamepadEvent;…}