What is TypeScript?
TS and JS application setup
Setting up a TS app is similar to a JS one. All popular frameworks have tools for generating and scaffolding TS projects. Developers just need to select required options for the new project in their command-line tool. The boilerplate code is then generated automatically.
However, not all project setup tools provide out-of-the-box support for TypeScript. Sometimes developers have to take additional actions to get TS to work in your application. For this, they usually follow instructions from the selected framework’s manuals. Those additional requirements and settings are quite simple and quick to complete.
Migrating from JS to TS
Js vs.TS development speed
If you need to speed up feature delivery, developers can skip type checking. But doing this leads to the accumulation of technical debt, which negates the benefits of TypeScript. Developers should avoid skipping type checks and do it only in exceptional cases: for example, when a third-party library they use doesn’t have type definitions.
Code quality and app maintenance
With time the codebase of any application grows. So does the technical debt. In TypeScript apps, the technical debt accumulates slowly. The presence of types in the code makes relations between different entities more clear. Therefore the code is easier to refactor. Apart from that, type annotations together with the code editor’s features make refactoring fast and less of a hassle.
TS support in third-party libraries
Major JS frameworks and libraries — React or Angular — have TypeScript support. Some even have their code written in TypeScript. Still, less popular libraries may have neither out-of-the-box nor community-built type definitions. To use them, developers have to spend additional time creating custom type definitions. Alternatively, they can skip type checking in the code where the library is used.
Sometimes after another release of a new version of a third-party package, its type definitions become outdated. This often leads to type check errors. That’s why it’s important to update your project dependencies with a prior check of TypeScript support.
TS vs. JS bug fixing efforts
On the downside, developers who previously worked with scripting languages need to embrace a new way of thinking. On the upside, developers with knowledge of statically typed languages can master TypeScript very quickly and take advantage of all their previous experience.
Project onboarding time
When new developers join the team it takes some time for them to dive into the code and reach maximum productivity. TypeScript has type annotations that make code more readable for a developer who is new to the project.
Type annotations help to understand the application code and data flow faster, especially in large projects. It allows to engage developers from another team or hire a freelancer and get them familiar with the application quickly.
Finding the right people
TypeScript brings a lot of benefits for large-scale applications. For example, it helps developers to write clean and properly structured code and reduces the number of potential bugs.
Those benefits come at the price of slightly increased time for writing TypeScript code together with higher requirements for the developers’ qualification.