Closed d180cf closed 8 years ago
When you have overrides that is also an overload, you have to provide at least one overload that matches the overridden function. This is fairly clearly implied by the error:
interface MyElement extends HTMLElement {
addEventListener(type: "click", listener: (ev: MyMouseEvent) => any, capture?: boolean): void;
addEventListener(type: string, listener: EventListener | EventListenerObject, useCapture?: boolean): void;
}
This works nicely, indeed. Thanks!
Ultimately, what I want to do is to describe the following trick:
As you see, my
<div>
element intercepts all "click" events and adds a new property to them, so whoever attaches a "click" listener later will see this new property.A practical example would be a custom UI element that represents, for instance, a chess board, and adds
row
andcol
properties to every mouse event, as the consumers of the UI element shouldn't need to convert the plainx
andy
coordinates to the cell coordinates.My attempt to describe this failed:
tsc complains that the HTMLElement interface is incorrectly extended: