Hi guys,
I'm playing around with the JS backend and tried this snippet:
import dom, jsconsole
window.addEventListener("mousemove",
proc(event: MouseEvent) =
console.log(cstring"test")
)
I found this doesn't work with 1.6.0 and 1.6.6 but it does work with 1.4.8. I even tested with an earlier version, 1.2.2, and seems like it doesn't work with that version either.
When I'm using a version that doesn't work I get a Type Mismatch: required type for cb: proc (ev: Event){.closure.}. Pretty weird considering MouseEvent IS inherited by the Event object type. Anyone know why I get this error? What could be the difference between 1.4.8 and the other versions that would throw this kind of error?
The older versions 'incorrectly' allowed a procedure that took a child type to upcast into a procedure that takes a parent type. The solution is to either internally convert the parameter into the child
let event = MouseEvent event
or cast the procedure to the base
cast[proc(event: Event)](myProcHere)