Basic DOM Events
Basic DOM Events are defined in a file called lib.dom.d.ts. Search for 'interface Event' and you'll find the typings for the definition in the DOM specification.
Here is an excerpt:
/** An event which takes place in the DOM. */
interface Event {
/**
* Returns the object to which event is dispatched (its target).
*/
readonly target: EventTarget | null;
// many, many more properties
}
As you can see, this interface will satisfy your code. But be aware that 'target' can be null so respect this in your handleChange function:
const handleChange = (event: Event) => {
const target = event.target; // Event | null
if (target === null) {
throw new Error('target can not be null');
}
// targets type is now Event
setValue(target.value); // target.value is of type EventTarget
};
React Events
Others asumed that you're using react. In this case have a look at the typings here.
You'll find something called 'SyntheticEvent' which is "a cross-browser wrapper around the browser’s native event".
Excerpt:
interface BaseSyntheticEvent<E = object, C = any, T = any> {
nativeEvent: E;
currentTarget: C;
target: T;
// many more properties
}
interface SyntheticEvent<T = Element, E = Event> extends BaseSyntheticEvent<E, EventTarget & T, EventTarget> {}
Which satisfies your code as well.
Read more about React Events here.