10 reasons to choose TypeScript over JavaScript.

Serge Hulne
2 min readOct 13, 2021
TypeScript vs. JavaScript. (C) by the author.

Without further ado, here are 10 reasons to choose TypeScript over JavaScript :

1. There is no such a thing as JavaScript, there are as many JavaScript as there are browsers and interpreters (for ES6, ES5, etc) not to speak of Node, Deno, etc….

2. Statically typed languages are more robust than dynamically typed languages.

3. TypeScript is to JS what « hints » are to Python : a way to simulate some aspects of a compiled language by treating bugs before run time (typically at compile-time) based on hard-coded variable types.

4. Using TypeScript with VSCode, you can detect a lot of errors at coding time which would pass unnoticed with JavaScript (it is better handled in VSCode).

5. When using TypeScript, you can transpile your code to any JavaScript dialect your target requires, no need to learn N flavours of antiquated JavaScript for I.E., etc.

6. TypeScript is a strict superset of JavaScript, therefore it is just « JavaScript plus types », (« ES6 plus types », basically), therefore the additional safety granted by using TypeScript comes at a very low cost to the developer.

7. TypeScript is more pedagogic than JS because it prepares programmers to make use of typed languages such as Go, Rust, C++, Swift, etc.

8. TypeScript has a sane treatment of classes: classes in TypeScript behave essentially like classes in C++, Python unlike classes in JavaScript, especially when it comes to define methods or use the “this” « pointer ».

9. Modern frameworks tend to encourage (if not force) the developer to use TypeScript rather than JavaScript (or at least who offer TypeScript as an alternative):

1. Angular (required).

2. React (optional).

3. Electron (being migrated).

4. Deno (supports TypeScript).

10. All in all, coding in TypeScript is faster than coding in JavaScript, because of the points 1–10, above. The extra-time used for adding type declarations is more than compensated for by the gain in additional debugging info from the linters (VSCode, etc) and by the ability to catch errors at coding time and/or compile time.

--

--

Serge Hulne

Author, scientist (Physics PhD), philosophy, Sci-Fi, thrillers, humor, blues and Irish music, green energy, origins of consciousness.