Hacker News new | ask | show | jobs
by matthewmacleod 2758 days ago
In my experience, retrieving external data is not the point at which Typescript is useful – it's usually safe to the make the assumption that whatever data you retrieve meets the contract you've already agreed. But it does prevent whole classes of bugs that I found were pretty common in plain JS:

- "This thing was null but you didn't account for this case" - "You should have a number here but something returned a string" - "You have made an invisible typo in a property name" - "You have not handled all possible values in this function" - "You accessed some data internal to a class that wasn't meant to be changed"

Basically my experience is that is substantially cuts down on the number of stupid bugs that end up in my code. The code completion is also fantastic!