type strORnum = string | number;
interface IUser {
name: string;
age: number;
}
type partialState = { [propName in keyof IUser]: strORnum };
interface IContext extends IUser {
setState?: (value: partialState) => void;
}
const changeHandle = (e: React.ChangeEvent<HTMLInputElement>): void => {
if (setState !== undefined) {
const {target: { name: nameProp, value }, } = e;
setState({ [nameProp]: nameProp === "name" ? value : Number(value) }); <--- Тут ошибка *
}
};
Текст ошибки
Argument of type '{ [x: string]: string | number; }' is not assignable to parameter of type 'partialState'.
Type '{ [x: string]: string | number; }' is missing the following properties from type 'partialState': name, age