I simply want to do this with my KeyboardEvent
var tag = evt.target.tagName.toLowerCase();
While Event.target is of type EventTarget it doe
@Bangonkali provide the right answer, but this syntax seems more readable and just nicer to me:
eventChange($event: KeyboardEvent): void {
(<HTMLInputElement>$event.target).value;
}
Could you create your own generic interface that extends Event
. Something like this?
interface DOMEvent<T extends EventTarget> extends Event {
target: T
}
Then you can use it like:
handleChange(event: DOMEvent<HTMLInputElement>) {
this.setState({ value: event.target.value });
}