Typescript is the present and future of Node/JS, move on!

Before you continue this is the best Tip I've for you:

Do not "LEARN" TypeScript, build your projects with it.

If you go down the TS rabbit-hole while trying to figure out what's good about it, You will ran into these tweet/videos/etc showing up some reeeally advanced code, making heavily use of the advanced features TS provides... they call them TS-wizards. So. maybe a dev who mainly during his career used plain JS this advanced TS may look way too intimidating.

You may start looking at that type of code if maybe you want to build or work on something like a lower level library that needs to abstract a lot of code, provide many interfaces, etc.

Here is an actual fact:

You don't need to be a Wizard or have a CS degree to start building and taking advantages of this amazing technology. If you are familiar with JS/Node or any other framework like React your are set!

Javascript

It is a dynamic language, where we can do all kind of crazy things, like:

  1. Reference variables that don't exist.
  2. Variables have no type.
  3. Work with objects with an unknown 'shape'.
  4. Code is interpreted by the browser / Node; --> But if your code is broken you won't catch it until runtime when the interpreter throws an error.

TypeScript

Strict superset of JS

It means when you open a TS file you can write plain JS, with all TS extra features being optional; but out IDE / analyzers provide feedback right when something is wrong as you type it: Example: using a variable that's out of scope.

Behaves something like a compiled language, and we can say javascript is the compilation "target"

Static type checking

This is the primary goal of TS: provide type safety, which is a huge benefit over JavaScript, this way you can catch errors at compile-time, rather than runtime. This means you can avoid many of the errors that commonly occur in JavaScript, such as typos, undefined variables, and incorrect function arguments. In the long run, this can save you a lot of time and effort in debugging your code.

For example, let's say you have a function that takes two arguments, a string and a number. In JavaScript, if you accidentally pass in the wrong type of argument, you won't know until runtime. But in TypeScript, you'll get a compile-time error that tells you exactly what went wrong. This can help you catch errors early and prevent them from causing bigger problems later on.

Better on your Editor of choice

TypeScript offers much better tooling than JavaScript. Because TypeScript provides type information, your IDE or text editor can offer intelligent auto-completion and error checking.


So, next time you start a new project; (whether inside React prison or not); add that --typescript flag to your init commands, you wont regret it :)

About
Related Posts
Comments
The comments are closed on this section.
Hire me!

I'm currently open for new projects or join pretty much any project i may fit in, let me know!

Read about what I do, or contact me for details.