top | item 7519652

Announcing TypeScript 1.0

265 points| kjbekkelund | 12 years ago |blogs.msdn.com | reply

115 comments

order
[+] bilalhusain|12 years ago|reply
The typescript playground[1], which lets you try TypeScript in your browser, looks so professional and finished when compared to CoffeeScript[2] or Dart[3]. As someone who attempted a half-baked Rust to JavaScript transpiler[4], I am floored with the packaging of TypeScript (tutorials, specs, editor integrations, npm, playground). At the moment, the only missing feature that my jealousy could point out is autoscrolling (see lexer example in my demo)!

By the way, is playground using v1.0?

[1] http://www.typescriptlang.org/Playground/

[2] http://coffeescript.org/ (Try CoffeeScript tab)

[3] http://try.dartlang.org/

[4] http://bilalhusain.com/rust-lexer/syntax.html

[+] couchand|12 years ago|reply
I don't think any of them are very polished or professional.

The CoffeeScript site reports errors unintuitively yet visibly in the top-right corner. The TypeScript site requires that you scroll right to the error and then realize it's not just your browser complaining about a misspelling. But both are better than the Dart sandbox, which basically only says "error".

None of them get page layout right. Dart and TypeScript have obvious input/output boxes, but both get demerits for their handling of overflow. Dart just grows the box which is acceptable, but TypeScript thinks their customized scroll bars are better than native. CoffeeScript handles overflow reasonably, but it's a big translucent overlay causing all sorts of moire on my screen.

I suppose if you're on a Windows computer you might be tricked into thinking the TypeScript page looks reasonable, since it probably fits in. For me, though, I'm having a hell of a time figuring out what's a button and what's not.

[+] keyle|12 years ago|reply
I am huge believer in typescript. This has made me consider html5 seriously for the first time.

There are still many dark spots (hello js scope, bs standards), but with Typescript I've already built stuff I could have only done AIR in the past.

I find it ironic that MSFT tried to compete with Flash with Silverlight (and failed I think), and to me, Typescript means end of the line for Flash/AS3.

The language is dead easy to pick up, and IntelliJ has been a really good IDE with it.

Highly recommended.

[+] radicalbyte|12 years ago|reply
We've been using TypeScript for 9 months now on a large project. It's fantastic. There's now way I'll go back to pure JavaScript again.

The type system just catches so many defects, and they're of the kind that are hard and boring to find (typos).

Plus IntelliSense integration (including jsdoc) is great.

On the downside, our project takes some time to compile so we had to build a tool to do it incrementally. Plus it doesn't play well with one-class-per-file structures (but I expect that to be fixed).

[+] axefrog|12 years ago|reply
Agreed, TypeScript is great, but the compiler is excruciatingly slow. I have to segment my app into multiple sub-build areas and only build a subset at a time, which is annoying because I frequently end up making small changes outside of that subset of code. My app is only around 25000 lines of code and a full compilation still takes around 50-60 seconds which, in a JavaScript workflow, is a lot of friction.
[+] benmorris|12 years ago|reply
Typos account for a significant amount of my javascript debugging. To have both intellisense and compile time checking for this would be a huge time saver.
[+] Kiro|12 years ago|reply
Can you give an example of a defect that the type system catched? You said typos but that's something JSLint would catch as well so not sure if it's a strong argument.
[+] skrebbel|12 years ago|reply
Most significant announcement IMHO:

> Today, we're announcing that we will begin taking pull requests for the TypeScript compiler and language service.

A relatively-flagshippy MS project becomes truly open source. This is awesome!

[+] jeremiep|12 years ago|reply
You're required to sign a CLA before you can contribute and they only accept pull requests for bugs.

Nothing prevents you from forking, but the main repository doesn't look 100% free.

[+] frik|12 years ago|reply
btw.

license: Apache License 2

[+] sytelus|12 years ago|reply
Having spent quite a bit of my dev life with typed languages and now coding a LOT in pure JavaScript, I'm actually not at all thrilled by TypeScript. Yes, pure JS is bit hard to maintain and it does occasionally pisses me off but at the same time it is liberating.

Not having to constantly keep adding types all over, not having to constantly refactor things because I now accept object instead of an int etc is refreshing. And best of all, not having compile at all is fast and simple. I'm only using JS frameworks that doesn't force me do build before testing the page and retains purity of JavaScript (that means no simulations of traditional OOP). Yes, sometime I do make bad mistakes and spend some time chasing down bugs that would have been caught in typed languages. However overall I find cost of adding types all over and maintaining them over the evolution of code is actually higher. It would have been really great if they had produced cool algorithms that could have inferred types as much as possible and added it as static analysis tool instead of JS extension.

Just because JS doesn't have type checking I'm now set in to mindset of doing quick tests of small changes, write more elaborate tests and so on. Even in moderately large project I think pure JavaScript is not only maintainable but also joy to work with compared to typed languages.

[+] klibertp|12 years ago|reply
I don't know very much about TypeScript, yet, but I'm doing some research and I'm going to advocate it on my next project. From what I already know:

> Not having to constantly keep adding types all over,

TypeScript is gradually typed (which means it's happy with as little or as much type declarations as you want to give to it) and uses type inference, which reduces amount of needless type declarations even more. Actually, coming from C and later C++ to Python and JavaScript I thought the same as you, that type systems are a complete PITA. I then learned OCaml and I changed my mind: bad, archaic type systems are PITA, but modern and powerful ones are a huge help and incur little cost.

> and retains purity of JavaScript

That's like saying that you're not using any Scheme library which implements convenient exception handling and you use bare call/cc instead.

Prototypal inheritance in JavaScript is strictly more powerful than most of the class based systems, but it is less convenient to express some common idioms using just what's built-in. This is why you're going to implement some kind of object and meta-object protocols on top of prototypes sooner or later. It makes sense to agree on a standard way to do it, otherwise you're just going to add yet another slightly incompatible object system. I agree that there are many cases where prototypal inheritance is enough, though, and you shouldn't use classes by default in JavaScript.

> adding types all over and maintaining them over the evolution of code is actually higher

I have vastly different experience here. Types tend to make refactoring rather easier than harder. It's because when you change a return value or expected argument of some function you don't need to grep for all its calls in the codebase - the compiler will tell you. With sufficiently good type system, the compiler will tell you if the new type is compatible with the old one, which makes writing adapters easier. And it all happens on compile time, which means you don't need to run your app to test it. I read that TypeScript compilation is slow - that may be, but I bet it's comparable to running all the unit tests for a project, for example.

> It would have been really great if they had produced cool algorithms that could have inferred types as much as possible and added it as static analysis tool instead of JS extension.

Yeah, I agree, I'd like it too. I remember there being a very cool project from some distinguished JS developer which did just that; it was an editor and a supporting library for checking and validating JS code. I can't remember what it was, exactly, though... Help, anyone?

> Just because JS doesn't have type checking

As I said, it's not either-or situation. Gradual typing is one thing, contracts are the other. You can have the best of both worlds. After a few years I'm still amazed with Racket and Typed Racket combo - it's exactly the right mixture of compile-time and run-time support for ensuring program correctness and I would like to have something very similar in JS one day. In the meantime, TypeScript is a step in the right direction. I only hope it will continue to evolve after 1.0 release.

[+] pjmlp|12 years ago|reply
> Even in moderately large project I think pure JavaScript is not only maintainable but also joy to work with compared to typed languages.

You will see that joy quickly fade away in enterprise projects.

[+] pingec|12 years ago|reply
>Not having to constantly keep adding types all over

You don't have to if you don't want to.

>not having to constantly refactor things because I now accept object instead of an int etc is refreshing

Again this is your choice, you can omit types if you want

TS gives you the option to add typing if you want it. And that is huge in my book, try refactoring a large enterprise app written in JS vs. written in TS.

[+] CmonDev|12 years ago|reply
"cool algorithms that could have inferred types as much as possible" - like Hindley-Milner type system? Like OCAML/Haskell/F#? There is only one reason JS could be chosen. Because it's everywhere. Almost any other modern language is realistically better. But unfortunately Web is Closed to JS/HTML/CSS.
[+] aquadrop|12 years ago|reply
TypeScript is the future of JavaScript, since all TS does is trying to introduce ES6 features right now.
[+] girvo|12 years ago|reply
Anders is my favourite language designer, ever :)

TypeScript is something I'm still trying to get more buy-in from my team, but the issue is the lack of decent autocomplete/static analysis in anything other than Visual Studio. I'm working on that problem myself, actually.

[+] nawitus|12 years ago|reply
I've had autocomplete with Eclipse, WebStorm and Sublime.
[+] paf31|12 years ago|reply
I use Cats IDE on a relatively large project and find it very good.
[+] rpwverheij|12 years ago|reply
+1 for IntelliJ. Their support for typescript is pretty good. I actually tried Visual Studio and IntelliJ's webstorm, and descided to go with Webstorm. Also the support has improved over time, though I'm still hoping for some nice code generation support for Typescript
[+] toggle|12 years ago|reply
It'd be great if there was a compiler that would compile TypeScript to asm.js [0]. Adding type-safety in TypeScript is only for the programmer -- when you compile it to Javascript, you don't get any performance increase. But, if you could compile it to asm.js, you'd actually get some performance increase out of it. (Note: I don't know much about TypeScript or asm.js, so if what I just said is completely untrue, I'd love to know why.)

[0]: http://asmjs.org/

[+] brandonbloom|12 years ago|reply
A well-typed subset of JavaScript (such as that produced by the TypeScript compiler) follows some very simple rules. Modern JS engines will recover 95+% of that performance automatically thanks to optimizations such as "hidden classes". This is also true of code that conforms to the Google Closure compiler's "type system", and by extension to idiomatic code produced by all of the more advanced compile-to-JS languages.
[+] Touche|12 years ago|reply
asm.js requires you to manage your own memory. TypesScript doesn't, it's a pretty thin layer on top of JavaScript.
[+] ajanuary|12 years ago|reply
You wouldn't be able to compile it to asm.js because of the very different memory models, which means you wouldn't be able to take advantage of any alternative runtime paths the js runtime has for asm.js.

You could, however, use the type annotations part of the asm.js spec to take advantage of the fact most js runtimes are going to be attempting to optimise the heck out of them.

[+] CmonDev|12 years ago|reply
If the goal is to produce asm.js you can use a language better than TypeScript. Asm.js has not much to do with JS in spirit.
[+] jbm|12 years ago|reply
Could someone be so kind as to explain why I should consider Typescript over Coffeescript in future projects?

I've been using CS for the past year or two, but I'm hearing a lot of buzz around TS for the past few months. It would be really nice to have a better idea as to why it should be best to move now - is it really that much better?

(I love the CS tools available on PyCharm; they really made my life easier. That said, I think that there are similar TS tools available as well)

[+] untog|12 years ago|reply
One reason (as I see it) is that TypeScript is implementing ES6 features along with the type-specifc stuff, so it's going to end up in a place where it's very compatible with the 'future' of JavaScript.

CoffeeScript will always be something quite different. I love it, but that difference makes me nervous. ES6 ought to bring a lot of the features I like about CoffeeScript into JavaScript.

[+] mahmud|12 years ago|reply
Coffee is to Type Script what indentation is to type theory.
[+] perimo|12 years ago|reply
I contribute to the Doppio JVM project (https://github.com/int3/doppio), which we initially wrote in Coffeescript. About 9 months ago, we decided to port the whole thing (~10kloc) to Typescript, and it proved really useful:

- Typescript is a superset of Javascript (mostly), so we ported by converting all the Coffeescript sources to Javascript and renaming them with .ts extensions. There was a bit of cleanup involved in getting modules to play nice together, but most of the code ran without modification.

- The JS that the Typescript compiler generates is much easier to read, in part due to less "magic" in the language.

- It also makes performance much easier to reason about, for the same reasons. One issue that bit us several times was Coffeescript's auto-return feature, which was invisibly accumulating large arrays of values from our interpreter's bytecode loop! This is no longer a concern with the current Typescript codebase.

- The inner workings of the JVM are fairly complex, so enforcing types at compile-time actually does catch bugs before they happen.

[+] jbeja|12 years ago|reply
Typescript is just a superset of JS, what does that mean?

Is just your regular js, but with some stuff added like type

check, classes, interfaces and some cute operators, just the

language that most know with some goodies added to help

with development, that is and that all, in oppose to CS that

is just syntatic sugar with others cute tricks that make the

language more appealing to people like you (assuming by your

post that you are a python developer). So if you are into JS

or type check then you should give TS a try, if not then

just stick with CS, only you can answer is changing

transpiler in your workflow is gonna make your life easier.

[+] pekk|12 years ago|reply
Maybe I'm just waiting for TypeCoffeeScript ;)
[+] bprater|12 years ago|reply
The article is light on 'What is Typescript'. Can someone explain what TypeScript is?
[+] lmkg|12 years ago|reply
It's a compile-to-JavaScript language, like CoffeeScript. Differentiating features:

- Strict superset of JS. All(?) JS is valid TS, making it easier to migrate to TS.

- Many of the added features are from EcmaScript 6, i.e. JavaScript Of The Future. TS lets you use those today, instead of waiting for browsers to implement.

- (Optional) type system, which some people are fans of.

- Much stronger tooling & IDE support, in part due to the typing.

[+] dkarapetyan|12 years ago|reply
Anders is a really good language designer. Everything this dude touches turns to gold. He was also behind C# and as far as enterprise languages go C# is a joy to work with. TypeScript is the same way. It's all really well thought out and instead of getting in the way the type system actually helps because you can leverage the dynamic aspects of JavaScript during the prototyping phase and then gradually add types as the design is fleshed out. Typed Racket I think is the other language that gives you similar capabilities but I haven't played enough with that one to have an opinion yet.
[+] oscargrouch|12 years ago|reply
Linq (cough)

Delphy (cough, cough)

[+] brokenparser|12 years ago|reply
The language is nice, but the compiler uses its own lib.d.ts which has all sorts of definitions for browsers and even proprietary MSIE ones. This doesn't make any sense when using TypeScript in any other context (like Gjs, NodeJS, Rhino, Seed, etc.). TypeScript shouldn't assume a browser by default, or at least provide an option for compiling without lib.d.ts.
[+] bsaul|12 years ago|reply
This project really is the greatest thing that could happen in computer science : a great mind trying to solve a problem in the most pragmatic yet elegant way to achieve the greatest possible benefit for developper with th minimal amount of time and work.
[+] keithwarren|12 years ago|reply
A little strong on hyperbole.

Less Flair version - Happy to see a well know and respected computer scientist trying to solve a problem faced by lots of developers and doing it in a simple and easy to understand way.

[+] xster|12 years ago|reply
Dart already happened
[+] RazvanPanda|12 years ago|reply
TypeScript IRC channel: irc://irc.freenode.net/#typescript
[+] pingec|12 years ago|reply
edit: The talk has ended now. Will update if I find a link to that talk.

Anders talking about TypeScript live: http://channel9.msdn.com/

[+] benawabe896|12 years ago|reply
I always get voted down for this, but I still feel that typescript is an answer to a question that nobody is asking. (I'm also very suspect of all of the positive comments. Is HN really this pro-MS for JavaScript?) In my company, we literally have a typescript counterpart team doing the same projects. Our code is cleaner, better architected, and our team is able to consistently produce 2 to 3 times more features. In my experience, the teams that choose typescript are usually windows devs that cannot wean themselves off of visual studio due to their dependence upon auto completion and IDE tools. I'm not hating, I just don't understand why any js dev would add code to their code.
[+] silentrob|12 years ago|reply
I was really hoping it would have a lib style compile api, but it seems fairly locked down. :(