You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
removeEventListener overloads should match the overloads provided for addEventListener #19386
addEventListener has a bunch of handy overloads to map things like: 'touchmove' to (ev: TouchEvent) => any etc. Unfortunately, the same overloads are not provided for removeEventListener. Normally that isn't a problem, but with the new strictFunctionTypes option, valid code is now producing errors.
Code
Compiled with: --strictFunctionTypes
functionhandleTouchMove(event: TouchEvent){}// Works fine because overloads are provided that map 'touchmove' to TouchEventwindow.addEventListener('touchmove',handleTouchMove,true);// This produces an error window.removeEventListener('touchmove',handleTouchMove,true);
error:
error TS2345: Argument of type '(ev: TouchEvent) => any' is not assignable to parameter of type 'EventListenerOrEventListenerObject'.
Type '(ev: TouchEvent) => any' is not assignable to type 'EventListenerObject'.
Property 'handleEvent' is missing in type '(ev: TouchEvent) => any'.
You can use the following type assertion to defeat the error, but I don't believe that should be necessary:
Activity
mhegazy commentedon Oct 21, 2017
We need to generate signatures for
removeEventListenterjust like we do foraddEventListener.Generate typed signatures for removeEventListenter
thebanjomatic commentedon Oct 21, 2017
I made a go at fixing this myself here: microsoft/TypeScript-DOM-lib-generator#312