💻Why TypeScript⚡

Katerina Sand
CheckiO Blog
Published in
6 min readAug 7, 2020

--

The CheckiO team has recently made an informed decision and switched our JavaScript CheckiO portal to TypeScript. This action resulted in a complete renewal and restructuring of the js.checkio.org. We still believe that JS is an awesome programming language. Despite that, TS is rapidly going viral and offers a lot additional tools, while supporting all of the JS properties and functions.

In this article, we will highlight the main points why we have considered moving to this JavaScript superset a good idea, which will be very beneficial, whether you are a JS purist or an open-minded enthusiast coming from C# or Java.

Basic info 📑

Over the years of evolving, JavaScript code started to become messier and harder to handle. This was painfully obvious especially in the large projects. The requirement to compile the whole application in order to run it didn’t help the matter. Using JS on the enterprise level as a server-side tech was too inconvenient.

In view of this raising necessity to have a more maintainable and organized code, which can be effectively used in the expending front-end projects, TypeScript came to being. The project itself was created and led by Anders Hejlsberg (a software engineer who is very famous for various projects, like Delphi, C#, Turbo Pascal, etc.) at Microsoft. BTW, he is still very much involved in the TS open-source process on GitHub.

The main idea behind the TS project is to broaden JS features. To put it bluntly, TypeScript is, basically, a strongly typed JavaScript with tools embracing object orientation features. It’s much more efficient for application-scale development.

Benefits of TS over JS 📊

📌 Bug radar 😈

The tricky part of JS code is that it needs to be completed and run to determine whether it’s valid. Therefore, you might be stuck going through the various lines of code looking for what’s wrong with it. It will waste you so much time and nerve cells.

TypeScript’s transpiler, on the other hand, using static typing provides you with the particularly useful error-checking feature that will certainly catch any kind of syntax mistakes. TypeScript has a linguistic service supporting autocompletion, which is accompanied by the powerful editor integration. TS recognizes what’s available for a particular object in terms of methods and properties, so the editors sees it as well. All of it provides you with contextual tips while you are writing your code. Also, there are plug-ins for almost every editor you can think of at your disposal. You can instantly check your code right in the editor.

It’s very helpful, since you don’t need to wait and run the code. You’ll see the errors right away!

Besides that, typing allows you to keep everything in place, so there are fewer chances to have improper assignments.

📌 Dev friendly 🤗

For a long time JavaScript is considered to be the main language of the web, since just about any web app (even mobile and desktop apps) use it to some extent. But JS has certain shortcomings (components, objects, modules), which makes it not particularly useful in large scale projects.

TypeScript possesses all that lacking in JS. It’s much better for working on complex applications. TS simplifies the JavaScript code, hence to maintain a vast codebase in it is a piece of cake in comparison. Additionally, any developer will appreciate the variety of included tools.

📌 Trial by combat 🔥

Of course, JavaScript had a long time to prove its strong sides and usefulness. Nevertheless, TS is a great choice for projects where there is more than one person managing a significant codebase. If you check out some of the projects where TypeScript has been used (Angular, VS Code, Dojo 2, Notable, Aurelia, Asana, Slack), you’ll see its worthiness.

Angular2 presents one of the projects written in TypeScript. Victor Savkin claims that the biggest selling point was the advances TS tooling (like navigation, refactoring, autocompletion), which is a must-have for large projects. Also, TypeScript interfaces make it possible to explicitly define abstractions, which may help avoid a lot of errors. Not to repeat ourselves with the advantages already indicated in other points, TypeScript takes the most useful things and adds it to the JS ecosystem without dismissing JavaScript itself.

Same benefits considered choosing TypeScript as the development language for Aurelia.

Currently, many frameworks are using TypeScript, like Ember and Glimmer, Ionic and NativeScript to some extent.

TypeScript is quite credible and it has a lot to offer to any substantial project.

📌 Stronger team 💪

You no longer have to depend on other developers too much. And it’s actually a good thing. The strictly typed language like TypeScript gives the opportunity to concentrate on individual tasks and bring in new team members much faster. It’s not that hard to understand what code is about anymore. You no longer feel the urge to bother your co-workers with various questions and they aren’t wasting time trying to explain what code does and how. You can find out all you need from your complier and IDE.

Even when you have the need to consult with somebody relating your code, it won’t cause them hours of frustration and possible further resentment. I’m kidding, of course, but with the confusing JS code, it will certainly distract your co-workers from their tasks for quite a while. Therefore, time lost, energy levels dropped, productivity reduced.

Another road it all can go with a messy code is if you can’t figure things out on your own and you don’t want to distract anybody. Not considering the time you gonna put in to make sense of things, you can end up being the sole reason for various bugs emerging on production. You probably already guessed what it’ll cause you and your team.

All of it shows that having understandable and organized code really saves your time, your team members’ time, and increases the performance of each developer on the project, as well as the whole team.

📌 Switching is simple 😊

There is no need to blow your brains out learning the intricacies of a new programming language. TypeScript is just JS with a type system layered on top. Nothing too fancy. So, going from one to another shouldn’t be very difficult.

Conclusion âš”

The CheckiO Team, considering our portals to be a practically learning environment, is always trying to keep up with the latest updates and developments. So, why not to use all the advantages Typescript provides for the JS programmers? It won’t diminish your JavaScript skills, but actually expand the things you can do with your code, making it ea§sier not to get mixed-up in silly errors and slowed-down by large unorganized code structure.

Besides, you can always get support from the TS community and get involved in the quickly moving open-source process of adding new features and trends.

--

--