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

Feature request: have more specific parameter typings #14

Closed
bvanderdrift opened this issue Nov 1, 2019 · 0 comments · Fixed by #15
Closed

Feature request: have more specific parameter typings #14

bvanderdrift opened this issue Nov 1, 2019 · 0 comments · Fixed by #15

Comments

@bvanderdrift
Copy link
Contributor

When using element.useEventListener where element: HTMLElement there are two overloads (source):

    addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;

This enables the type checker in an IDE to defer the type of the event argument that is passed into the handler.

For example

buttonElement.addEventListener("click", (event) => doSomething());

will have IDEs recognize event as type MouseEvent.

I would suggest adding the overloads to the types of this package as well to enable that IDE feature.

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 a pull request may close this issue.

1 participant