What are the main differences between Babel and TypeScript

Solution 1:

TypeScript is a superset of JavaScript that compiles down into plain JavaScript (ES3+). The main goal of TypeScript is to enable developers to leverage excellent static typing capabilities. It is suitable for large applications that would benefit from features like:

  • Type annotations & type inference.
  • Generics.
  • Interfaces, enums, namespaces, modules and classes (the latter two available in ES6).
  • Safe refactoring.

As far as I am aware, Babel simply "transpiles" newer ECMAScript features down into a format that is supported by older ECMAScript environments. It is suitable for developers who want to write plain JavaScript using newer language features.

Solution 2:

Victor Savkin one of angular 2 developers talks why they selected Typescript over other technologies.

http://victorsavkin.com/post/123555572351/writing-angular-2-in-typescript

the last section Why Typescript?

"There are a lot of options available to frontend devs today: ES5, ES6 (Babel), TypeScript, Dart, PureScript, Elm, etc.. So why TypeScript?

Let’s start with ES5. ES5 has one significant advantage over TypeScript: it does not require a transpiler. This allows you to keep your build setup simple. You do not need to set up file watchers, transpile code, generate source maps. It just works. For many small projects this simplicity outweighs the advanced refactoring and navigation capabilities TypeScript provides. You just know where all the code is, and what it does.

ES6 requires a transpiler, so the build setup will not much different from TypeScript. But it is a standard, which means that every single editor and build tool either supports ES6 or will support it.

Elm and PureScript are elegant languages with powerful type systems that can prove a lot more about your program than TypeScript can. The code written in Elm and PureScript can be a lot terser than similar code written in ES5.

Each of these options has pros and cons, but I think TypeScript is in a sweet spot that makes it a great choice for most projects. TypeScript takes 95% of the usefulness of a good statically-typed language and brings it to the JavaScript ecosystem. You still feel like you write ES6: you keep using the same standard library, same third-party libraries, same idioms, and many of the same tools (e.g., Chrome dev tools). It gives you a lot without forcing you out of the JavaScript ecosystem."