I don’t see any mistakes from you. I also did try to write your code in my visual studio code and I got no errors.
if it’s running well it’s probably just a false error message from IntelliSense. Restarting visual studio code may fix it if you have not tried it already.