I just started styding TypeScript and unfortunately I could not find solution of my problem. I have a list of checkbox. I add the value of unchecked checkboxes into the array. But TS shows mistake on event.target.value Argument of type 'any' is not assignable to parameter of type 'never'.
Checkbox
<Checkbox
className={classes.checkbox}
icon={item.icon}
onClick={props.switchType}
checkedIcon={item.icon}
name="checkedH"
value={item.title}
color="primary"
/>
And event
const switchType = (event: React.ChangeEvent<HTMLInputElement>) => {
const currentIndex = checked.indexOf(event.target.value);
const newChecked = [...checked];
if (currentIndex === -1) {
newChecked.push(event.target.value);
} else {
newChecked.splice(currentIndex, 1);
}
event.target.value is undelined by red color in both variants.
Aucun commentaire:
Enregistrer un commentaire