I'm working on a large code base that could benefit from Typescript, but since eventually the world will be moving to ES6, should I steer the development towards Traceur?
I don't want to change Typescript implementations in order to target ES6 (when is ready), so my feeling now is to go ahead with Traceur.
Can anyone advise?
ts" file. TypeScript is the ES6 version of JavaScript with some additional features.
Yes. You can target TypeScript compiler to ES6.
Modern browsers support all ES6 features, so ES6 is a good choice. You might choose to set a lower target if your code is deployed to older environments, or a higher target if your code is guaranteed to run in newer environments. The target setting changes which JS features are downleveled and which are left intact.
Then I discovered that the default transpilation target for tsc is ECMAScript 3.
I definitely do not agree with the opinion that TypeScript and Traceur are so different, TypeScript is ES5 with types and Traceur is just about ES6.
On the one hand there is an ES6 compatible TypeScript 2.0 in progress. On the other hand there are a couple of features in Traceur marked as experimental in docs, namely types and annotations. And it turns out that types are very similar to the TypeScript types whereas annotations are something irrelevant both to ES6 and TypeScript. So Traceur is more just ES6 and there is already name for that: AtScript. Yes, we have another language extension :-)
There is a nice slide from Miško Hevery presentation that shows what is really going on here, fully valid as soon as TypeScript 2.0 is released:
So whatever you decide to use, it is important to note: they are subsets, you may write ES5/ES6 JS and it will be valid TypeScript code, you may write TypeScript and it will be valid AtScript code.
Turning back to your question, I would give the humble advise to start with ES6 using Traceur with experimental features turned off (it is pretty stable now) and extend as needed, because this is not so radical a decision, doesn't lock you in and leaves space to move in the future.
UPD: At the beginning of the 2015 I would also recommend to pay attention to 6to5 project (renamed to Babel) as an alternative to Traceur. It moves very fast and provides has some nice features, such as readability of generated code and better support for node.js and build systems.
TypeScript and Traceur have completely different goals and aren’t comparable in the way you are trying to compare them.
TypeScript is a superset of EcmaScript that adds strict typing. It includes some features from ES6, but its primary goal is to add strict typing to the language (while aligning with ES6), not to provide ES6 support.
In contrast, Traceur is a future-EcmaScript to current-EcmaScript compiler. It doesn’t add anything to the language that isn’t already proposed for the next version of EcmaScript.
If you just want to write EcmaScript 6 today, use Traceur. If you want optional strict typing and all the benefits that go along with that, plus some ES6 features, use TypeScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With