5 ms·
The most underrated feature of TypeScript is not the language itself, but the transpiler. With the flick of a switch you can support ES3, ES5 and in future ES6
by smegel 10y ago
The most underrated feature of TypeScript is not the language itself, but the transpiler. With the flick of a switch you can support ES3, ES5 and in future ES6 and beyond - without changing your code (not entirely true, but it is possible to write code that transpiles well to all JS standards).
Decoupling your development from the shifting sands of JS support - across multiple browsers and platforms - is a dream come true, and a good enough reason alone to use TS.
- labrador 10y agoTotally agree. After doing a bunch of code with TypeScript (transpiling to ES5 and ES3), I decided to give Babel a try. It took me awhile to set it up properly with the right presets and plugins. It did a fine job transpiling, but I wondered why people just don't use TypeScript. It's so much easier to use.
- marcus_holmes 10y agobecause I enjoy writing pure JS. Typescript feels like Coffeescript, which always felt like a hack to make Rubyists more comfortable. Similarly TS feels like a hack to make C#'ers more comfortable. Ultimately, if you're going to program in JS then get comfortable in JS, rather than trying to make JS more like your favourite language.
- labrador 10y agoSome people like types, other people don't. Some people like indenting with 4 spaces, other like 2. I was a die hard 4 space guy until today, when I was debugging a bunch of 2 space code and decided I like it better.
- wiredearp 10y agoI have a solution for hardcoded spaces that is sure to blow your mind.
- labrador 10y ago8 charwidth tabs in Go are a sight to behold - what decade is this?
- wiredearp 10y agoYour editor will however default to 4 charwidth tabs, but you can change this whenever you feel like it and that's the point. It's just a setting, so we can all have our own and then we don't have to argue about it. This morning you like 2 spaces of indent because you can see more code; but this evening you like 8 spaces because the beer makes the code hard to see. It's true that the code appears locked to 8 spaces when you view it in a browser on GitHub (and that's basically why a majority of developers use spaces still in this decade) but you can also change this whenever you feel like it by placing an ".editorconfig" file in the root of your GitHub project, little known fact. In your case, you would simply change the tab width to 2 and then you don't have to commit all your files again and ruin it for everyone who prefers 4. Serious answer.
- addicted 10y agoYou can type absolutely pure JavaScript, change the file extension to .ts and still get some of the benefits of the typescript compiler for absolutely free. That's probably why a lot of people are excited about typescript. It basically is JavaScript, but optionally annotated JavaScript. It's not a new language.
- cies 10y agoNot when using the billion-dollar-mistake-fixing `--strictNullChecks` flag. :)
- wtbob 10y agoBut if you're going to transpile, why not transpile from a real language, not a Turing tarpit?
- smegel 10y agoWell Google already did that with Java and GWT, but it never caught on. I guess TS being a superset of JS itself might be an advantage...otherwise it is still a new language designed for web browser programming unlike Java. I suppose it is a fair question why they didn't just use C#.
- aikah 10y ago> Well Google already did that with Java and GWT, but it never caught on. Actually it did catch on in the enterprise world, just like Typescript. Will Microsoft be as "dedicated" as Google regarding its language? wait and see.
- Cthulhu_ 10y agoThere's also Scala.js, which takes it even further than GWT. And of course Dart.
- _pmf_ 10y ago> Well Google already did that with Java and GWT, but it never caught on. ClojureScript uses the Closure(sic) compiler from GWT to compile Clojure/Java to JavaScript (not that I defend this technological train wreck). > I suppose it is a fair question why they didn't just use C#. This would have been superb, but I think Microsoft wanted to show that they "get" web developers; just mentioning C# causes the JS pundit get jittery because someone wants to limit the amount of write-only code he is able to spit out.
- PretzelFisch 10y agoThere were already open source projects that tried to do this some paid projects, but they never gained traction. Microsoft also had the hind sight of DART and GWT to help point them in the TypeScript direction.
- gjolund 10y agoJust a warning, people said the same thing about coffeescript. I love TS, and am finding more and more ways to inject it into old codebases. However I remember what happened with coffeescript and am sure to always clearly document my build pipeline in case someone needs to move away from TS in 5 years.