Description: Want to get started with TypeScript but not sure if it’s worth it? Here are the pros and cons of the language proven by practice.
Is TypeScript Worth Using?
There are a lot of articles that dwell on its many advantages and weaknesses already. This one exists to show you some insights that I drew for myself while developing a rather big application.
The Advantages of TypeScript
Here are the main benefits of the language:
- Strong typing
- Code readability
- Wide IDE support
A strong typing in TypeScript allows you to describe properties and methods of objects and classes more fully than with other languages. This makes for an opportunity to stop checking all the arguments incoming in a function or a method. You will probably find this a real timesaver.
Here’s what it used to look like:
TypeScript makes this a lot easier:
Now, let’s get to the next point. Strong typing really facilitates the following one.
One of the many things that TypeScript accomplishes is giving you the typing to check the incoming arguments with fewer lines of code. You end up with the code that doesn’t have the unnecessary elements.
Now compare this to what a TypeScript code would look like.
It’s like getting the best custom essay writing services US can offer instead of getting your buddy to write it. A lot less of unnecessary text.
In some cases, you can reduce the lines you have to write with abstractions in JS. This doesn’t work in all cases, though. TS is far more advanced in this respect.
A lot of people in coding are reluctant to use JS because it seems too chaotic and unpredictable. This is where TS comes into play. It allows you to write JS in a way you can understand easily.
Backward compatibility with JS
This is a very pleasant bonus. Being backward compatible with JS allows you to keep the code you already have and still use TypeScript.
Wide IDE support
All major IDEs support TypeScript today. This includes IDEA, WebStorm, Sublime, and Atom.
So you can stick to what you know and love instead of changing it. As you see, TS is an easy language to experiment with.
The Drawbacks of TypeScript
Now that you know the upside, let’s get to the downsides of this language. Here they are:
- Strong typing
- What if it goes extinct?
You’ve seen this point in the advantages. What is it doing here? It’s not an error, it can just work against you as well.
There’s even a bigger problem associated with TypeScript. It’s the migration of already existing solutions to JS. It is possible, but the way it’s done is extremely time-consuming.
You have to create a .d.ts file for every imported JS library. The file should contain all types that are returned and describe all methods.
It may be fast for a small custom library, but imagine what it’s like to create .d.ts for jQuery.
TS compiler makes it easier for you because it’s essentially foolproof. It will adjust all the missing commas and misspelled variable names. That’s good, right?
You’ll have to update the compiler as well. TypeScript is changing, and you will probably need to update the compiler or even learn new elements of the language. If it does change that much, you may need to rewrite some of the existing code.
Any developer needs to know how to debug their code fast. You have to check the code for errors and find new bugs all the time. There’s a lot of guides that describe the process of doing this already. You can find dozens for debugging TS in different IDEs, and it’s not the point of the article.
What if it goes extinct?
TS is not an easy language to settle on. With this article, you have the insight to make an informed decision.