Some reasons to stick with Javascript instead of using Typescript

There are many reasons that a developer may want to stick with Javascript, instead of applying Typescript to their codebase.

  1. The project is small-scale and easily manageable.
  2. Don’t want to bother with compilation.
  3. New syntax has a bit of a learning curve, or simply not wanting to put in the extra work.
  4. Not quite understanding the benefits of Typescript

That last one is a bit tongue-in-cheek; but to some extend Typescript does force you to do more work (even if just a little), on top of regular Javascript.

But let’s dive in and take a look!

Small scale project

In some cases, choosing Javascript may simply be practical. It could be a small hobby project or a node-script with a couple of files, just to test something. It could be a basic API with a few endpoints, or a minimal application to play with a library.

In these – and more – instances it is completely fine to use Javascript!

Setting up Typescript and getting it to compile does take a bit of work and isn’t necessarily straightforward. It comes with the hassle of more tooling, whereas Javascript just runs, on the V8 engine that Node utilizes.

In other words, it’s very straightforward and simple to get going, using purely Javascript.

This ties nicely into our next topic..

Skip compilation

When using Typescript, the project requires some tooling to compile Typescript to Javascript we can then run. It can be inconvenient having to re-compile code between every change, especially if that means restarting an express (or similar) server.

Skipping compilation and using plain Javascript is just faster. You write your code and enter node file-name.js and voilá. That’s it!

With Typescript you may need tsconfig, webpack, babel or similar tooling to compile into Javascript before running, and if you just want to run or test something ‘real quick’ it can be bothersome having to setup this tooling.

New Syntax

The primary concern I’ve seen when people are hesitant to get into Typescript is that they worry about the syntax. It can be perceived as a “oh now I have to learn yet another language” type of mountain to climb.

Having to add in : any or as unknown and similar blocks that is inconsistent with Javascript patterns can seem daunting and confusing, especially if one were to get into Typescript from reading an existing codebase.

I would definitely recommend reading the official docs instead!

On a related note I have also heard yet others justify their unwillingness to learn Typescript, because they’re afraid it will be a “poor mans Java” which they definitely do not want to learn.
I don’t know much Java but Typescript still seems to be bringing the best from Javascript while just ensuring that we produce fewer errors.

And that brings us to the last point!

Misunderstanding Benefits

Often getting into something new requires a spurt of motivation or to some extend setting aside some uninterrupted time to understand what we’re getting into.

Not taking the time to understand what benefits are brought with Typescript will definitely hold someone back from learning it.

When I first got into Typescript, I didn’t fully understand the benefits either. It felt clunky to have to add all this new syntax while it still wasn’t clear why I was doing it.

It also felt wrong adding : any everywhere because I didn’t quite understand what else to put there to satisfy the compiler. I was often left wondering “what exactly does this tell my codebase? Am I introducing errors”.

I’ve since learned that very rarely will Typescript be the cause of errors.

Much more commonly we have some piece of Javascript code that was working fine, but is throwing compiler errors in Typescript, because it we forgot to check types or object or property existance.

But these are some of the greatest benefits from Typescript: Having the ability for your IDE to tell you “hey you, I think you forgot to check if user exists, as it may be undefined at this point” is a great help once you get used to it. It’s already helping us produce fewer runtime errors!

While Javascript is great and can do many things, and the above are fine reasons to not get into it, I would still very much recommend that you do.

I personally had some starting trouble learning Typescript, but once I was a few weeks in I was absolutely loving it and seeing the benefits everywhere. That feeling has only increased since, as I have gotten better about using Typescript in more intelligent ways.