DEV Community

Discussion on: Need help to fix a problem

Collapse
 
shaegi profile image
Marvin Semmelroth

Hi,
I believe what youre looking for is keyof

Since typescript doesn't know that name is a key of your object you can cast the name to be keyof account by simply changing the line

    accountCopy[name] = value; // update value from input element value

to

    accountCopy[name as keyof User] = value; // update value from input element value

hope that helps :)

Collapse
 
touhidulshawan profile image
Touhidul Shawan • Edited

Thanks, ❤ . This was very helpful. It worked