Hi, I believe what youre looking for is keyof
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 :)
Thanks, ❤ . This was very helpful. It worked
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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
to
hope that helps :)
Thanks, ❤ . This was very helpful. It worked