-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScript
Milestone
Description
TypeScript Version: 3.3.3
Code
const handler = (event: MouseEvent) => {}
document.addEventListener('click', handler); // OK
document.addEventListener('auxclick', handler); // NOT OK:(Actual behavior: throw error
Argument of type '(event: MouseEvent) => void' is not assignable to parameter of type 'EventListenerOrEventListenerObject'.
Type '(event: MouseEvent) => void' is not assignable to type 'EventListener'.
Types of parameters 'event' and 'evt' are incompatible.
Type 'Event' is missing the following properties from type 'MouseEvent': altKey, button, buttons, clientX, and 25 more.
Playground Link: http://www.typescriptlang.org/play/index.html#src=const%20handler%20%3D%20(e%3A%20MouseEvent)%20%3D>%20%7B%20%7D%3B%0D%0A%0D%0Adocument.addEventListener('click'%2C%20handler)%3B%0D%0Adocument.addEventListener('auxclick'%2C%20handler)%3B
(need to strictFunctionTypes on )
Is this bug or expected behavior? MDN says what auxlick has MouseEvent interface https://developer.mozilla.org/en-US/docs/Web/Events/auxclick
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScript