-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support { handleEvent() {} }
object interface as a listener
#4538
Support { handleEvent() {} }
object interface as a listener
#4538
Conversation
To run the tests:
|
Thanks, I had to install chrome using playwright but I could run the tests with that command! |
export type EventHandler<E extends TargetedEvent> = { | ||
bivarianceHack(event: E): void; | ||
}['bivarianceHack']; | ||
}['bivarianceHack'] | EventHandlerObject<E>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked for my projects, but I'm still cautious of changing an exported type. It might be necessary to leave this intact and instead add to the attribute interfaces one-by-one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to cause issues elsewhere (see #4581), though I'm not quite sure what it's even doing? If you have a moment, would love an explanation. A lot of this TS stuff flies right over my head
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll reply in the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers, and no rush! If that's incorrect usage then fair enough too! I'm very much unfamiliar with what this is doing.
if (options.event) e = options.event(e); | ||
return "handleEvent" in eventHandler ? eventHandler.handleEvent(e) : eventHandler(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method must be called using the dot syntax; pulling it as an intermediate value would prevent it from receiving the object as this
. The alternative is .apply()
/.call()
but I suspect that would add even more to the size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet, thanks!
Currently a draft because I couldn't get tests to run.