I don't understand TypeScript

2016-04-29 Last modified on 2021-05-24

A few days ago I gave a talk with Romain at Devoxx France, about frontend JavaScript and the hype of frameworks. I was able to listen to 2 talks where TypeScript was mentioned.

typescript

Here are a few personal thoughts about my interactions with the TypeScript world.

The representation we have of TypeScript is wrong

There are a lot of articles or presentations depicting TypeScript as a superset of ES5/ES6 (and more). Something like:

typescript is wrong

TypeScript is actually compatible with 60% of ES6:

kangax stats on compilers and polyfills

Even the current page of the french wikipedia is misleading about the reality of TypeScript:

Is supports the ECMAScript 6 specification.

Wikipedia article about TypeScript

TypeScript is not a standard

At Devoxx, I heard that «TypeScript also embeds features from the future ECMAScript specs, add types, and it will become the standard».

Maybe, but not for now and the next few years.

The evolution of the ECMAScript specifications is a process that takes time, with multiple people involved (TC39). The evolution of the specification is not handled by a single authority (like Microsoft with TypeScript) to define the next versions.

IDE oriented

The output file is plain JS, matching a version (ES5, ES6) that you will define.

So, all this extra-typed-sugar for nothing ? Yep.

Using TypeScript is currently only sugar in your IDE, and I am not found of the idea of choosing a specific language for that.

Is it for me ?

I don't think so.

Maybe TypeScript can make onboarding of junior developers understand how things are structured in a big project.

This was a punchline from this talk:

People coming from C# or Java won't be lost !

Look at this example from Angular 2:

An example with angular and TypeScript

It's like... Java.

But, how can you code without types ?

JavaScript has types. They are dynamically inferred.

You can beat the averages with a dynamically typed language...

Since the typing is optional in TypeScript, the debate about types is another story :p

Tooling, tooling...

Since TypeScript compiles to JavaScript, you have to add a build step to your project for this.

You also surely need the typings package to manage TypeScript definitions files (see the DefinitelyTyped registry).

The end

Well... I am a JavaScript developer (even if I made some Java before), and I like the language. People working with JavaScript should stick with JavaScript.

Will TypeScript really win? And why Dart wasn't able to win ? Only the future will tell us.

Note: I am not a fan of CoffeeScript or Babel either, we have to much tooling to do before really coding, but that's another story about fatigue...