**** TypeScript
Tags: javascript, typescript
Published: 2021-04-27 02:48:14

I am so sick of TypeScript.

No, that's not entirely true. TypeScript is fine.

I'm sick of people saying garbage like "No developer who uses TypeScript will ever go back to JavaScript."

I'm a JavaScript developer. I've been working in JavaScript for 15 years.

Let's dive into this.

Benefits of TypeScript
----------------------

I understand why TypeScript was created. TypeScript was created to:

1. Help large, ultra-complex projects eliminate entire classes of bugs
1. Make the boundaries between apis and sections of codebases clearer (_very helpful for large projects/teams_)
1. Give dev tools (_like IntelliSense_) additional information so they can be more useful

It does these things extremely well.

**Something to keep in mind**

The point of development is not to write perfect code. The point of development is to produce useful things, gain understanding, and grow over time.

Benefits of JavaScript
----------------------

JavaScript is an elegant language. It's syntax is relatively simple and extremely flexible. This has lead to things like [CoffeeScript](https://coffeescript.org/), [LiveScript](https://livescript.net), and the rise of [transpiling](https://scotch.io/tutorials/javascript-transpilers-what-they-are-why-we-need-them) (_which has lead to an explosion of helpful tools for development - and allows us all to use the coolest new features of JavaScript before they're fully supported by browsers_).

JavaScript also supports a wide variety of coding styles. For a developer, their coding style is their voice. Crucially, JavaScript gives developers many, many options to choose from when finding, crafting, or evolving their coding style.

Additionally, JavaScript is the simplest, fastest way to get a project from zero to doing something useful. Period.

**Something to keep in mind**

The elegance that enables all this comes at a cost. That cost is implicit knowledge. Implicit knowledge is the collection of things you know, but that you forget you know because you're so used to them. Implicit knowledge is the lifeblood of JavaScript.

An example of implicit knowledge is truly understanding how `this` works in JavaScript. Once you get it, you hardly ever think about it because you write code is ways that don't cause problems.

The More You Know
-----------------

Most problems people face when working with JavaScript are symptoms of inexperience or lack of knowledge; people lacking the implicit knowledge to understand (_or, at least, have some idea_) why problematic code is behaving a certain way.

To people in this situation, TypeScript can end up looking like much more of a savior than it actually is.

TypeScript is basically just a [linter](https://www.freecodecamp.org/news/what-is-linting-and-how-can-it-save-you-time/) with a lot of context. Linters can be useful, but they provide no value _on their own_. Why? Because they don't actually _do_ anything. They just take away options.

For someone new to JavaScript, or new to programming, this can be very helpful. When there is only one way to do something, the path forward is clear.

It's crucial to understand, however, that TypeScript _is_ JavaScript. It's not a distinct language. When your code executes, it's executing JavaScript. Just JavaScript.

Another way to think about TypeScript is JavaScript with [blinders](https://en.wikipedia.org/wiki/Blinkers_(horse_tack)) on. Blinders help a horse go straight, but cause all kinds of problems when they fall off mid-race.

At some point a problem will occur that TypeScript cannot help with. When that happens, all the intrinsic knowledge about how JavaScript works under the hood _not_ gained via trial and error will be felt. And it will hurt.

Problems with TypeScript
------------------------

TypeScript's rules can easily clutter code to the point that it's intent gets muddled. Sure, the _types_ the code is working with are extremely clear, but what the code is actually _doing_ gets harder to understand as that's not the only thing you're focusing on when reading it. TypeScript adds [cognitive load](https://en.wikipedia.org/wiki/Cognitive_load). In some cases and for some people that additional load is worth it and the code overall benefits.

In some cases the cognitive load added by TypeScript is _not_ worth it. A senior JavaScript developer, for example, may not benefit from TypeScript as the rules it mandates may be redundant or, worse, counterproductive; the senior developer understands JavaScript well enough that they don't need TypeScript to make things explicit or remove options.

Removing options can be helpful. It can also unnecessarily complicate or bloat code.

Additionally, for projects that are not massive and ultra-complex, or projects with small (_possibly even one-person_) teams, TypeScript may not provide any value at all as everyone may already be on the same page and/or _want_ different coding styles in the codebase so team members can learn from each other.

Closing thoughts
-------------------

JavaScript offers about the lowest-possible barrier to entry for people wanting to get into programming and web/app development. Artificially raising that barrier by claiming that "real developers" use TypeScript instead of JavaScript helps no one.

Each developer deserves to find, and have, their own coding style; every developer deserves their own voice.

TypeScript has it's place, so does JavaScript.