2 ms·
Providing a thorough answer to your question would require a lengthy article. It's a bit much of an ask to have someone do this for you on HN. But very briefly
by Oddskar 6y ago
Providing a thorough answer to your question would require a lengthy article. It's a bit much of an ask to have someone do this for you on HN.
But very briefly I would say that these are the benefits as I see it:
* Access to improved tooling. E.g. refactoring by renaming things is much easier to do without breaking things. Also auto-complete when using third party libraries is a huge benefit.
* Some errors are automatically caught during build-time. E.g. checking the data used in a template lines up with what the component should be passing to that template. Without typescript one should probably verify this via unit tests. With TS these tests are superfluous.
* Improved documentation. It's a lot easier to understand what the shapes are of data is that is being passed around in the application. It also provides the opportunity to define these in central locations (e.g. in the form of interfaces) which can then have additional documentation added to them.
I think the benefits are not so much specific to TS as they are general benefits of using types and a typed ecosystem.