I have the following typescript function, the purpose of this function is to modify the property of an object dynamically :
const test = (data: any, propertyName: keyof Test1, x: Test1) => {
x[propertyName] = data;
}
Here is the "Test1 type"
type Test1 = {
test: string;
test1: number;
test2: string;
}
In my "test" function, it gives me the following error :
Type 'any' is not assignable to type 'never'
I guess the problem comes from the type of "data" but I don't know how I can change it. Thanks for your help !