addEventListener and Event subtypes ?
vendethiel opened this issue · 4 comments
vendethiel commented
Hi,
what's the normal procedure to use addEventListener
with, say, KeyboardEvent
? (maybe the function param type needs to be T forSome { type T <: Event }
)
I'm currently using .onclick
but that seems like a bad idea :).
sjrd commented
I haven't found better than taking an Event and then cast it inside.
lihaoyi commented
Does it work with partial functions? e.g. { case e: KeyboardEvent => ... }
?
sjrd commented
It should, indeed.
lihaoyi commented
Likely there isn't any better solution till singleton types for literals or some equivalent mechanism becomes available. Until then, cast away! It's the wild west of the web and you don't need to be so prudish and typesafe.