My thoughts on TypeScript

author pfp

lecongly

After learning and using TypeScript in some project for a while, here are my thoughts on TypeScript.

1. A Super set of JavaScript

Typescript uses the same syntax as JavaScript with nifty additional features.

Typescript is just like JavaScript but has a strict syntactic structure with stringent datatype rules.

2. Type safety

The type system in TypeScript, the set of rules on how to assign data types or types for short to variables, objects and other elements of my code is very stringent. Though JavaScript has type safety but TypeScript is stronger.

3. Code Hinting

My favourite part of typescript is its ability to present hints while I code. When combined with powerful code editors like VS Code or WebStorm, the contextual code suggestions helped me reduce errors and increased my typing speed

4. Error message

Available separately the linter when enabled in the editor, can detect errors of syntactic, type and even contextual nature. It presents the errors by underlining the error part with red squiggly lines as I type. This makes error correction easier and faster.

5. Versatility

What makes typescript versatile is its wide variety of configuration options. I can enable and disable different options to cater to my project’s needs.

One of the settings I used a lot is the target option. It flipped between commonJS module system and the es5 module system while learning.

Conclusion

As a beginner, all these strict rules felt time-consuming since it took less time to write the same in JS. Over time, I realized the usefulness of TS and started using its features as I learnt them. I’ve decided to use typescript in my next side project instead of JavaScript.

No Rights Reserved@lecongly• ©2024