10 reasons to choose TypeScript over JavaScript.

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.

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Hooked on Hooks

How to sign your Expo App (by Google Play) successfully

Angular 9/8 Authentication Form: Angular FormBuilder, FormGroup, and Validators Example with Node…

Angular 10 Authentication Form Example

Hi folks,

npm-project-directory

Migrating from Redux State Management to React’s useReducer

Rails: scopes with arguments and joint tables

Parameters and Arguments in JavaScript

Running ExtJS App as a Liferay Portlet: Part 2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Serge Hulne

Serge Hulne

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

More from Medium

Loading Third-Party JavaScript

Signing JavaScript objects with Symbol and Proxy

Functional programming : Avoid Side Effects

Temporary Dead Zone(TDZ)