Hacker News new | ask | show | jobs
by place1 3277 days ago
Type errors might not be the biggest issue up-front when writing new frontend code, but refactoring JS becomes really hard as the LOCs grow. Typescript (static typeing in general) really helps with this as you can get instance feedback about how you're changing interfaces between parts of the system.

Another reason i've enjoyed TS is the editor intellisense support. It's really helpful when using a library to get type info in your editor instead of having to google when you forget what a function returns, for example. This is also helpful when you're coming back to code you wrote a long time ago, or a colleague wrote it, and you don't know what particular variables/function arguments/object properties are at a given spot in the code.

2 comments

Oh yeah, that's another great point (although you're still stuck with the fact that somebody can access object properties by key).
Couldn't you solve this with privates, either via a naming convention or with symbols, as well as using getters?
Not really. If I declare that an object has property xyz obj.xyz and obj['xyz'] are both valid ways of addressing it.
Absolutely. Typing is a real timesaver as it adds so much to how much an ide can help you.