Which type should be used for checkbox event onchange when implementing pure javascript with typescript?
const checkbox = document.querySelector("#myCheckbox") as HTMLInputElement;
function handleCheckboxChange(event: ChangeEvent<HTMLInputElement>) {
if (event.target.checked) {
console.log("Checkbox is checked");
} else {
console.log("Checkbox is not checked");
}
}
checkbox.onchange = handleCheckboxChange;
The above approach results in the following error message
type ChangeEvent = /*unresolved*/ any
Cannot find name 'ChangeEvent'.