Skip to content

Auxclick event handler has arg with Event interface #29995

@Thisman

Description

@Thisman

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

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions