Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: register custom events into GlobalEventHandlersEventMap #27

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fredj
Copy link
Contributor

@fredj fredj commented Feb 6, 2024

Without this, I get the following error with:

profile.addEventListener("over", (event: CustomEvent<OverDetails>) => {});
No overload matches this call.
  Overload 1 of 2, '(type: keyof HTMLElementEventMap, listener: (this: HTMLElement, ev: Event | ErrorEvent | UIEvent | AnimationEvent | MouseEvent | ... 13 more ... | WheelEvent) => any, options?: boolean | ... 1 more ... | undefined): void', gave the following error.
    Argument of type '"over"' is not assignable to parameter of type 'keyof HTMLElementEventMap'.
  Overload 2 of 2, '(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void', gave the following error.
    Argument of type '(event: CustomEvent<OverDetails>) => void' is not assignable to parameter of type 'EventListenerOrEventListenerObject'.
      Type '(event: CustomEvent<OverDetails>) => void' is not assignable to type 'EventListener'.
        Types of parameters 'event' and 'evt' are incompatible.
          Type 'Event' is missing the following properties from type 'CustomEvent<OverDetails>': detail, initCustomEvent ts(2769)

One alternative is to use as EventListener

@fredj fredj requested a review from gberaudo February 6, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant