My daily job is client developer using AngularJS. We are evaluating if we want to go with TypeScript. I did some research on typescript and almost every JavaScript package I need must have definition type files. I found that is not very convenient, especially if I would like to try something new and they don't have the definition for it. Its really frustrating. (Even the current jQuery definition gives me some problems if I want to use typescript 1.5 beta). I started looking at ES6 and it looks similar to TypeScript. Should I just use ES6 instead? Also, I heard angular 2 will have full support for TypeScript, will that be one reason I should stay with it?
-
11You don't need a definition file everytime for something new. If you want to use a library without type you can write `declare var MyNewLibraryName: any;` then use it as you please without the compiler complaining. – David Sherret Jun 12 '15 at 17:52
-
2With the votes to close this question, I would suggest asking more of the pros/cons associated with each approach rather than asking which is the best, this way you're asking for information and not for opinions. – Brocco Jun 12 '15 at 19:17
-
1typescript updates javascript new version feature before all major browsers, my option is to use typescript and compile to javascript version based on your target browsers. ( of course even it easy to transpile javascript one version to other ) – bhv Feb 27 '17 at 06:59
-
If you're not bothered about being able to lint your code correctly, and you want Immutable.js to be really hard to work with, and you love writing boilerplate, and you think DRY is overrated and you actually prefer repeating yourself, and you enjoy writing type definitions for other people's code, and you like managing types as they change underneath you, and you enjoy switching between two different text editors because nothing out there works properly, then choose Typescript. But if you're sane, choose ES6/7 and Babel. – gargantuan May 03 '17 at 09:42
2 Answers
Decision tree between ES5, ES6 and TypeScript
Do you mind having a build step?
- Yes - Use ES5
- No - keep going
Do you want to use types?
- Yes - Use TypeScript
- No - Use ES6
More Details
ES5 is the JavaScript you know and use in the browser today it is what it is and does not require a build step to transform it into something that will run in today's browsers
ES6 (also called ES2015) is the next iteration of JavaScript, but it does not run in today's browsers. There are quite a few transpilers that will export ES5 for running in browsers. It is still a dynamic (read: untyped) language.
TypeScript provides an optional typing system while pulling in features from future versions of JavaScript (ES6 and ES7).
Note: a lot of the transpilers out there (i.e. babel, TypeScript) will allow you to use features from future versions of JavaScript today and exporting code that will still run in today's browsers.

- 5,964
- 4
- 46
- 80

- 62,737
- 12
- 70
- 76
-
6
-
17@RaoulRubin That is true, there are a lot of other factors, but for a closed question on here it at least provides a starting ground for the decision making process – Brocco Feb 01 '16 at 16:27
-
1
-
1in market perspective what is the value of TypeScript against es5 or es6 – Ravinder Payal May 17 '16 at 05:14
-
@RavinderPayal that is a much larger discussion that the starting point of this answer. Plus that answer would be largely opinion-based and therefore not manageable on stackoverflow (like this question as well) – Brocco May 17 '16 at 14:54
-
-
3@RavinderPayal has an interesting question, Brocco. From a market perspective, what _is_ the value of TS vs es5 or es6 and stuff along those lines? – J.Wells May 18 '16 at 00:22
-
1Well, from a development perspective, if you want generators and stuff along those lines, you might want to use Babel instead. – Ben Lesh May 18 '16 at 00:33
-
-
1Do you want to use ES6 + types? You might try Flow: https://flow.org/ – joseluisq Apr 26 '17 at 13:45
-
-
3Ok, so this post is a couple years old/. Let's fast forward to today, September 28, 2017. Are most browsers supporting ES6? – Dewey Banks Sep 28 '17 at 20:24
-
1@DeweyBanks [http://kangax.github.io/compat-table/es6/](http://kangax.github.io/compat-table/es6/) – Ciarán Bruen Oct 09 '17 at 14:10
I've been using Typescript in my current angular project for about a year and a half and while there are a few issues with definitions every now and then the DefinitelyTyped project does an amazing job at keeping up with the latest versions of most popular libraries.
Having said that there is a definite learning curve when transitioning from vanilla JavaScript to TS and you should take into account the ability of you and your team to make that transition. Also if you are going to be using angular 1.x most of the examples you will find online will require you to translate them from JS to TS and overall there are not a lot of resources on using TS and angular 1.x together right now.
If you plan on using angular 2 there are a lot of examples using TS and I think the team will continue to provide most of the documentation in TS, but you certainly don't have to use TS to use angular 2.
ES6 does have some nice features and I personally plan on getting more familiar with it but I would not consider it a production-ready language at this point. Mainly due to a lack of support by current browsers. Of course, you can write your code in ES6 and use a transpiler to get it to ES5, which seems to be the popular thing to do right now.
Overall I think the answer would come down to what you and your team are comfortable learning. I personally think both TS and ES6 will have good support and long futures, I prefer TS though because you tend to get language features quicker and right now the tooling support (in my opinion) is a little better.

- 1,155
- 1
- 13
- 30

- 4,319
- 3
- 19
- 23
-
40ES6 got no browser support? Both typescript and ES6 needs a transpiler. Means you are not running TS or ES6 on web, rather using something like Babel. TS into Angular 2 was added just for a political tie btw Google and MS – STEEL Oct 14 '16 at 18:39
-
42@STEEL No not a MS politician you are just responding to an answer I left over a year ago when ES6 support was very limited. And you are free to think the TS and Angular 2 decision was political but that doesn't change my point that it was written for that language and the Angular2 team is encouraging its use. – Kent Cooper Oct 16 '16 at 02:09
-
18This is from 2 years ago, but time has shown how the standard eventually prevails. ES6 is greatly supported natively by most browsers nowadays. Classes, arrow functions, etc. Eventually, we will get to a point where browsers will natively support a decent enough version of javascript to make transpilers unnecessary. Typescript will always require a transpiler. Why is this important? because it's our duty as web developers to push the web forward, and that's by supporting the standards – monzonj Jan 31 '17 at 16:05
-
4It's a bummer ES6 doesn't support actual "compile time" type safety. There's a lot of great stuff in ES6 but the fact that I can't say "this argument is a string (or instance of class X), dammit" and be able to have that verified as part of your build process is still bad for large programs (front end and back end alike). – Brad Peabody Mar 24 '17 at 07:20
-
You can use a tool like [Flow Type](https://flow.org/en/) to add type support to ES6 if you really want. Until ES6 becomes ubiquitous in all browsers, your toolchain will then consist of Flow->ES6->Babel which is a lot of indirection, but does the job and I think is a very popular chain presently. – Prahlad Yeri Jun 23 '18 at 10:48