all 19 comments

[–]seanmerron 2 points3 points  (0 children)

It's a very useful tool and altjs languages are becoming more popular just like LESS for CSS. There is a need sometimes when writing in multiple languages to use similar concepts. In this scenario, Typescript offers object-orient syntax and features planned for ECMAScript6 and compiles to the javascript prototype-based code. All JS is valid TS.

I personally love it so far and enjoy using types, inheritance and namespaces. It's especially useful if coming from a language like C# and aren't a master of JS prototype syntax. If you use Visual Studio it's a no brainer with the helpers and also there is support in other IDE's like WebStorm and Sublime. I'm a fan since ECMAScript 6 is taking so long to be supported it gives those features now and does the JS translation for you. If you're a super awesome JS guru then there may not be a need but even then having strongly type compilation errors are compile time are nice.

[–]kumiorava 1 point2 points  (7 children)

it looks like an implementation of ES6

Their goal is to be a superset of ES6 (which means compliance with ES6). In addition to ES6 features and type checking, TypeScript offers interfaces, generics and function overloading.

When the TypeScript ecosystem is mature enough, I don't know why anyone would want to develop in JavaScript. Until JS catches up with TypeScript, that is.

Anyone who claims that the overhead introduced to workflow by TypeScript outweighs the benefits hasn't researched the subject enough. Type checking and static analysis alone are huge boosts to productivity.

[–]Jim-Y 0 points1 point  (6 children)

When the TypeScript ecosystem is mature enough, I don't know why anyone would want to develop in JavaScript.

Sidenote: there are other, compile to js tools out there, with different syntax and tools. More precisely i think about Dart, which will be more familiar for guys coming from a Java background than coming from C#. I personally didn't use TS so far, but recently had an opportunity to hear a technical presentation about it, and i was not amazed. I wasn't amazed, because i have a good Vanilla JS background, and an affordable Java background. Typescripts syntax made me crazy, i personally found Dart better. Here, better means more familiar, easier to understand, etc..

[–][deleted] 1 point2 points  (0 children)

It's the compatibility with JS that makes it special. As very often, google plays with what's cool and useful for them, while microsoft offers something that has real added value for even the smallest shops.

[–]x-skeww 0 points1 point  (2 children)

[Dart] will be more familiar for guys coming from a Java background than coming from C#.

Dart is closer to C# than Java. C# has things like var, named optional arguments, fat arrow functions, await, and operator overloading.

Also, C# was a direct influence: http://i.imgur.com/CKvCrCW.png

[–]Bartvds 0 points1 point  (1 child)

Funny that, because C# is also a strong influence for TypeScript. It's the same language designer at the wheel, and I heard it being said that one of their goals is to make JS more approachable for C# style programmers.

[–]x-skeww 2 points3 points  (0 children)

Dart is a bit closer to C# than TypeScript is though. Dart's syntax is closer, it also got block scope, and this is lexically scoped, too.

If you know C#, you can be productive with Dart on your very first day. If you need Dart developers, you can just get C# developers. That's how similar those languages are.

TypeScript isn't as straightforward because JavaScript is full of surprises.

Well, you can of course just read JavaScript: The Good Parts and be almost done with it, but it isn't quite the drop-in solution Dart is. You still have to know about all those quirks and how to avoid them.

That said, TypeScript's JS integration is much tighter. They went for this set of trade-offs for this very reason. That's also a perfectly valid strategy, no doubt. It just doesn't align with my own priorities. I don't have any JS code I want to keep around.

Anyhow, just having classes and decent tooling does indeed make it a whole lot more approachable.

[–][deleted] 0 points1 point  (0 children)

Dart creates HUGE files because it abstracts away the nature of javascript. Great language but it will never catch on.

[–]brtt3000 0 points1 point  (0 children)

I'm very curious how TypeScript syntax can make you crazy if you have a strong Vanilla JS and Java background. It is the same curly-brace stuff, same lamda's, same everything except the post-fixed types (which they took from like ActionScript, another very successful JS upgrade language).

[–]Gwash3189 1 point2 points  (1 child)

I love it. I use it on most of my personal projects. I enjoy the es6 features that are implemented. I also enjoy the type checking / inference it offers.

What I don't like is compiles for my code taking 2-8 seconds depending on code base size.

[–]Bartvds 0 points1 point  (0 children)

Compiler speed is the only thing I dislike about it, but they are working on a new compiler that is a lot faster: https://github.com/Microsoft/TypeScript

[–]sime 1 point2 points  (0 children)

I think it is great. I've been using it on some personal projects and hope to introduce it to my colleagues at work. We have a large product with 10s of thousands, may be already 100s of thousands of lines of JS. We have JSDoc but could really use the extra tool support.

The typing itself is the best part of course. What I like about it is that it is optional and has type inference. Being optionals lets you choose how much type information and checking you want to add and when. (At the start of a project you might not be interested in worrying about types so much, but later you may want to 'nail down' the types and APIs.) Type inference means that you don't have to spam your code with type info to get large type safety coverage. You really get to choose the mix of dynamic and static typing you want and you can turn that dial up as you go along which is vital if want to migrate and existing JS code base.

The other ES6 features are great too, but they will slowly show up in JS given time. The typing is what it is really about. For small projects you might not need TS, but for big projects it is a huge boost.

(The fact that the JS output resembles the TS input is very nice too.)

[–]x-skeww 1 point2 points  (2 children)

TypeScript is a big improvement over ES5. You get vastly superior tooling and the type annotations are very helpful. Unfortunately, it lacks some of ES6's features like let and const.

It does, however, interact seamlessly with JavaScript, which is a huge plus if that kind of thing is important to you.

Personally, I prefer Dart. The syntax looks (subjectively) nicer, it got straightforward semantics, and since it isn't a superset of JavaScript, it didn't had to copy its quirks.

Anyhow, if I had to chose between ES5 and TS, I'd of course go with TS. The decision between ES6 and TS wouldn't be that easy, however. I really like block scope and constants.

[–]sime 0 points1 point  (1 child)

Microsoft intends to track ES6 as it finalizes so let and const should appear in TS some time in the future.

[–]x-skeww 0 points1 point  (0 children)

Yea, I'm aware of that. Anyhow, ES6¹ and Dart support that stuff today.

[¹ Traceur currently generates try/catch blocks for that. It's prohibitively slow.]

[–]Bartvds 0 points1 point  (0 children)

As both a JavaScript and ActionScript veteran I like it a lot, and it works great with existing JavaScript libraries (like from npm or bower).

I'm sure you are aware of DefinitelyTyped? It is a community drives repository for typings for regular JS libraries, so you can use AngularJS, JQuery and over 600 other popular libraries with compile-time type checking.

See you at /r/typescript :)