Why you should care to use Typescript ?

web application typescript

Typescript has been consistently gaining popularity over last few years and is becoming web developers new favorite. Typescript is a superset of vanilla javascript. Its a javaScript with syntax for types. TS is a statically typed language, meaning the data type for the variables in the code are known at compile time.

Due to this statically typed nature of TS, it becomes hard for the programmers to introduce undefined variable exceptions & perform inappropriate operations on data ( eg 10 + "20" ). Typescript can help developers minimize as much as 15% of bugs which would be occur if they would use plain JS Ref : Research studies published in IEEE.

Source

So Why Use Typescript ?

  1. Type Safety / Compile-time type checking

    Since typescript is a statically typed language, data types for different program variables need to be defined ahead of time. Typescript enables a feedback loop which highlights any compile time errors in projects. This prevents a lot of type errors which couldnt have been determined if written in plain JS. This is a BIG deal.

    TypeScript adds static typing to JavaScript, which means that variables and functions have a defined type that is checked at compile-time. This can help catch mistakes and bugs early on, and make it easier to understand and maintain your code.

Source

  1. Auto suggestions

    Typescript enables auto suggestions during programming. This is a huge productivity booster as you wont have to make rounds through the code to read through the function definitions. I feel this alone is a good upgrade from JS.

  2. Interchangeability

    Typescript is a superset of javascript. All javascript code can be written in typescript but the reverse is not fully true. If you are a web developer building applications in react JS , you can slowly move to typescript. TS and JS both can co exist in the same project. So if you are starting to migrate to TS, you keep your existing code in JS while adding new TS code.

  3. Relibility

    TypeScript is reliable and easy to refactor. This enables developers to evade errors and do rewrites much easier.

  4. Self Documenting and Readability

    Typescript is self documenting.Since all types are defined explicitly, its easier for engineers to read and contribute to code written by others in the team.

Source

  1. ES6 modules and classes, private class fields support

    Typescript by default supports all the ES6 modules and classes. A lot of JS runtime do not offer such support.

  2. Improved code quality

    TypeScript can help improve the quality of your code by enforcing best practices and design patterns, such as encapsulation and separation of concerns. This can make your code more reliable, scalable, and maintainable.

  3. Better tooling

    TypeScript has better support from tools and IDEs, such as code completion, refactoring, and error highlighting, which can make it easier and faster to write and debug code.

  4. Improved scalability

    TypeScript can help you build larger and more complex applications more easily, by providing features such as interfaces, classes, and modules, which can help you organize and modularize your code.

  5. Stronger community

    TypeScript has a strong and active community, with many developers and companies using it in their projects. This can make it easier to find resources, help, and support when working with TypeScript.

Resources