EventWithCurrentTarget<T, E>
ts
type EventWithCurrentTarget<T, E> = E & object;Allows setting the currentTarget property of a generic DOM event to a specific type of HTMLElement. This is useful when you want to ensure that the currentTarget is of a specific type.
If the generics are not passed, the defaults are HTMLElement and Event.
Type Declaration
currentTarget
ts
currentTarget: T;Type Parameters
T
T extends HTMLElement = HTMLElement
E
E extends Event = Event
Example
ts
div.addEventListener('click', (event: EventWithCurrentTarget<HTMLButtonElement>) => {
event.currentTarget.disabled = true;
});