DEV Community

Discussion on: 5 easy wins for cleaner Javascript code 🧹

Collapse
 
mlevkov profile image
Mikhail Levkovsky

You’re absolutely right! I forgot to type it! Will update the gist shortly. Thanks for the catch

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.