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

Type of `delegate(Element, string, EventType, Handler)` doesn't seem to work #6

Closed
bfred-it opened this issue May 6, 2019 · 6 comments

Comments

Projects
None yet
2 participants
@bfred-it
Copy link
Owner

commented May 6, 2019

These work in TypeScript:

delegate(".base", ".clickable", "click", handler);
delegate(select.all(".base"), ".clickable", "click", handler);
This doesn't

But the Single base element specified overload doesn't:

delegate(select(".base"), ".clickable", "click", handler);
      TS2345: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'string | ArrayLike<Element>'.
  Type 'null' is not assignable to type 'string | ArrayLike<Element>'.

cc @nickytonline

@bfred-it bfred-it added the bug label May 6, 2019

@nickytonline

This comment has been minimized.

Copy link
Collaborator

commented May 6, 2019

I'll take a peek at this tonight.

@nickytonline

This comment has been minimized.

Copy link
Collaborator

commented May 7, 2019

It looks like you need to make the elements parameter type EventTarget | Document | Element (or maybe HTMLElement as well or instead of Element) on this line, https://github.com/bfred-it/delegate-it/blob/master/index.ts#L118

@bfred-it

This comment has been minimized.

Copy link
Owner Author

commented May 7, 2019

D'oh. PR welcome to get the blame 😅

@nickytonline

This comment has been minimized.

Copy link
Collaborator

commented May 7, 2019

Didn't have time last night to PR. I'll do it later tonight.

@bfred-it

This comment has been minimized.

Copy link
Owner Author

commented May 9, 2019

I think… that’s because select returns HTMLElement | null
I’ll try again with select()!

@bfred-it

This comment has been minimized.

Copy link
Owner Author

commented May 9, 2019

Indeed it was! Sorry about the noise 😅

@bfred-it bfred-it closed this May 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.