Why use Typescript?

Salonix__
2 min readJul 6, 2021

Since its creation/launch, Typescript has grown in popularity. Have you ever wondered why typescript is so popular? What is the point of having extra dependencies and languages if everything can be done in Javascript? Why add complications? I learnt about certain benefits of Typescript and decided to use it in all of my future projects. Let’s take a closer look at them. I will keep this blog short and informative.

What is Typescript?

TypeScript is an open-source language that builds on JavaScript, one of the world’s most used tools, by adding static type definitions. Types provide a way to describe the shape of an object, providing better documentation, and allowing TypeScript to validate that your code is working correctly.

Broadly, it has two types:

  1. A syntax: let s: string = 'str';
  2. A transpiler: takes the TypeScript and converts it into standard JavaScript

Advantages

Easy to debug: You’re essentially specifying the type of what you’re anticipating, which will obviously aid debugging.

Can be gradually adopted: You don’t have to write 100% TypeScript. Valid JavaScript is still valid TypeScript so you don’t need to jump into it 100% at the beginning.

Easier Refactoring: Typescript will automatically tell you if you forget to update/declare any argument.

Let your text editor/IDE help you more: TypeScript is compatible with almost all editors. This allows your editor to autocomplete and inform you what to supply to a function/component using TypeScript declarations.

Easy to read and understand components: With TypeScript, it’s easy to define Prop types, making the code much easier to read and use. And this will accompany by IntelliSense support plus static type checking.

There are some downsides as well, such as having to learn a new language, syntax, and so on. It becomes more difficult because new dependencies must be installed.
But, in my perspective, it’s all worthwhile.

This concludes this blog. I’ll come up with more fascinating blogs later.

--

--