DEV Community

Discussion on: 5 easy wins for cleaner Javascript code 🧹

Collapse
 
solarliner profile image
πŸ‡¨πŸ‡΅οΈ Nathan Graule

It's not only about Typescript typing; TS is right about changing the type of your variable because you're assigning a completely new value to it. Doesn't matter if it's an User object, or a string or a number, she the assignment, user is an object with the specified values in it. The User prototype is lost.