EventWithCurrentTarget<T extends HTMLElement = HTMLElement, E extends Event = Event>
ts
type EventWithCurrentTarget<T extends HTMLElement = HTMLElement, E extends Event = Event> = 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 Parameters
T
T extends HTMLElement = HTMLElement
E
E extends Event = Event
Type Declaration
currentTarget
ts
currentTarget: T;Example
ts
div.addEventListener('click', (event: EventWithCurrentTarget<HTMLButtonElement>) => {
event.currentTarget.disabled = true;
});