News for hackers. Stuff that matters.
Re:Announcing TypeScript 0.9.1 by jzelinskie on Tuesday August 06, 2013 @09:03PM (#6170216)
I haven't heard much about TypeScript since its original announce. Are any big projects using it? Does anybody have some commentary on their experience using it and where they think the project is going?
Re:Announcing TypeScript 0.9.1 by shearnie on Tuesday August 06, 2013 @09:24PM (#6170272)
My project isn't huge, but larger than it could have been using idiomatic javascript.

The scoping with modules and the typing really helped since I'm familiar with C# and having "everything light up" in the IDE. Saved a ton of time letting a compiler catch things instead of writing tests.

I tried coffee script, but found the copy/paste option for javascript that I have already written won me over.

Re:Announcing TypeScript 0.9.1 by de90 on Tuesday August 06, 2013 @09:33PM (#6170299)
Exactly my feelings about it. Being able to specify types, and having the compiler warn me of mistakes is a godsend when comparing it to just writing javascript.

And when valid javascript is valid typescript, it seems odd to not opt to use it when the only addition is a compile step to ensure sanity.

Re:Announcing TypeScript 0.9.1 by aquark on Tuesday August 06, 2013 @09:30PM (#6170294)
Same here -- I rewrote all my javascript code in Typescript and am very happy with the result.

No longer am I concerned about errant semi-colons or a stupid typo in a method name on an error handling path that a unit test missed.

Re:Announcing TypeScript 0.9.1 by wiradikusuma on Tuesday August 06, 2013 @10:43PM (#6170505)
There's js2coffee.org to copy paste JavaScript to CoffeeScript.
Re:Announcing TypeScript 0.9.1 by trentmb on Tuesday August 06, 2013 @11:48PM (#6170700)
... just for it to be 'compiled' back to JavaScript...
Re:Announcing TypeScript 0.9.1 by cageface on Wednesday August 07, 2013 @12:59AM (#6170938)
Transparent integration with native Javascript is a huge advantage for Typescript over things like Dart, I think. The ability to gradually introduce typing into an existing codebase is going to make adoption so much easier.
Re:Announcing TypeScript 0.9.1 by janekk on Wednesday August 07, 2013 @09:07AM (#6172512)
That's exactly what I've found. We ported all of our JavaScript code to TypeScript because of this, and are on a hunt to remove 'any' types.

We found a bunch of real and potential bugs due to JavaScript's dynamic nature, particularly with regards to the number of function arguments (JavaScript being happy to ignore extra parameters or replace missing parameters with undefined).

Re:Announcing TypeScript 0.9.1 by ajanuary on Wednesday August 07, 2013 @03:54AM (#6171428)

    Saved a ton of time letting a compiler catch things instead of writing tests.
Types should never mean writing less tests :/
Re:Announcing TypeScript 0.9.1 by CmonDev on Wednesday August 07, 2013 @04:11AM (#6171485)
Static typing means automatic language-integrated type-checking unit tests. I would bet a lot of dynamic language unit testing has to do with compensating for the lack of proper type checking. It's just like using patterns compensates for lacking language features.
Re:Announcing TypeScript 0.9.1 by ajanuary on Wednesday August 07, 2013 @04:38AM (#6171573)
I don't like to think about type checking as unit tests because they approach the problem from a fundamentally different direction, and I worry conflating them could lead to writing the sort of bad unit tests people are talking about here.

Type checking, or static analysis in general, checks for the presence of a particular class of errors.

Unit tests check for correct behaviour, and in doing so imply a lack of any errors, types or otherwise.

While it can be good to use unit tests to check for regressions in a specific error, the core of your tests should be specifying the behaviour of your system, not trying to catch out any specific class of errors.

If your tests are busy looking for specific errors, there will always be some that you miss (type checking, even in Haskell, misses a lot of classes of error). If your tests check for correct behaviour, there can be no errors.

Of course, writing tests with perfect coverage and specifying all the behaviour is impossible, even more so when you've got actual features to get out the door. So any static analysis you're comfortable with can be great for making up some of the slack, but let's not pretend that in most cases we shouldn't now need to be writing those tests to check it does what it's meant to.

The place where this approach sometimes falls short is on the public API boundary, as I mentioned in my other post. Types can be useful there, so maybe my original assertion was a little too strong, but still types should very rarely mean less tests.

(Apologies if the post is a bit all over the place, redrafting on a phone is hard)

Re:Announcing TypeScript 0.9.1 by CmonDev on Wednesday August 07, 2013 @08:54AM (#6172428)
I understand your point, thanks.
Re:Announcing TypeScript 0.9.1 by CmonDev on Wednesday August 07, 2013 @04:20AM (#6171517)
Did not mean dynamic languages are bad. They are awesome for scripting on the static type language core. Unless you like writing _lots_ of basic unit tests.
Re:Announcing TypeScript 0.9.1 by exit on Wednesday August 07, 2013 @04:00AM (#6171448)
i see people writing tests for the structure of returned objects

type annotation tests that at compile time

Re:Announcing TypeScript 0.9.1 by ajanuary on Wednesday August 07, 2013 @04:21AM (#6171518)
That suggests to me they're missing tests that check the data held in the objects.

There might be some worth in checking the structure of an object (including attached functions) as it leaves a public api, especially in a language like Javascript that plays it so fast and loose with object construction.

That's one of the nice thing about typescript - you can use it where it's most helpful and leave it where it's not.

Re:Announcing TypeScript 0.9.1 by jlebrech on Wednesday August 07, 2013 @06:30AM (#6171858)
he's right, you can cover more code using integration tests with a static typed language, unit test are then testing the functionality of individual classes.

especially for testing return types as C for example you assign those.

In C it's more popular to write example code which uses the library, and the errors are spotted at compile time.

Re:Announcing TypeScript 0.9.1 by emehrkay on Wednesday August 07, 2013 @12:14AM (#6170783)
Interesting. Is there a higher level lang that ONLY adds type safety and compile-time checking to JS?
Re:Announcing TypeScript 0.9.1 by egonschiele on Wednesday August 07, 2013 @12:32AM (#6170847)
Sounds like typescript v0.1 :) Seriously though, since all typescript features are optional, why do you want a language that doesn't have them at all?
Re:Announcing TypeScript 0.9.1 by hrjet on Wednesday August 07, 2013 @12:48AM (#6170904)
I was writing a biggish weekend project. It was mostly client-side logic with a FireBase backend.

I developed the first prototype in pure JS and there were some bugs (due to me being new to this FireBase model, and some hastily developed code).

I then converted the whole thing to TypeScript, because I prefer static typing. It took some time to setup: upgrading to the latest nodejs, collecting all type definitions for popular libraries, etc. The DefinitelyTyped[1] library is a great resource. But there were some warts in it. I had to make some PRs to this library for some missing methods in jQuery.

But right after finishing the setup, I was able to find and fix a complicated sequencing bug. That alone was worth the trouble of the setup cost.

I then tried using TypeScript for another project (this one had a licensed IDEA available). Here the setup cost was even lower. There are plugins available for Typescript in IDEA. Though I couldn't convince everyone in the team to switch to TypeScript.

This was back before they added generics support. Now that generics is added, I think there is hardly any excuse left to not use TypeScript (or a similar alternative).

What would make TypeScript awesome is support from more IDEs (Eclipse especially).

[1](https://github.com/borisyankov/DefinitelyTyped)

Re:Announcing TypeScript 0.9.1 by yareally on Wednesday August 07, 2013 @02:04AM (#6171151)
> What would make TypeScript awesome is support from more IDEs (Eclipse especially).

There exists a plugin for eclipse, but I have never tried it. I'm mostly an Intellij IDEA user.

http://marketplace.eclipse.org/content/typescript

Re:Announcing TypeScript 0.9.1 by santialbo on Wednesday August 07, 2013 @04:15AM (#6171494)
I just wish they update the built-in code analysis to use TypeScript 0.9. I don't like having to use outdated type definitions.
Re:Announcing TypeScript 0.9.1 by zcrar70 on Wednesday August 07, 2013 @06:39AM (#6171884)
Using it on some new functionality at http://rplan.co.uk, pretty pleased so far. The language is great, with some really neat features such as using interfaces for structural typing (http://en.wikipedia.org/wiki/Structural_typing) and declaring properties in the constructor definition. The ability to progressively type code is obviously quite nice too. Coding speed is typically quicker than JS because the compiler catches bugs that might take longer to surface (especially when integrating components.) Refactoring is also easier thanks to both the type system and tool support.

The compiler speed is OK (well, 0.9.0 wasn't, but 0.9.1 should be back to where it was before.) The main pain point is that we usually want to type any 3rd party JS we interface with (e.g. Angular, Backbone, Highcharts etc.) though https://github.com/borisyankov/DefinitelyTyped is helpful with this. No major complaints as of yet.

It's still perhaps too early to tell how long MS will be supporting it. Windows 8 has a JS interface which is comforting, but they could turn around and decide to stop development on it. That would be a great shame, but the code is open source, the compiler works well as of today, and the generated JS is readable enough that it can be edited.

We're slowly migrating over from Coffeescript.

Re:Announcing TypeScript 0.9.1 by boromi on Tuesday August 06, 2013 @10:52PM (#6170527)
The largest project I know using it from what anders has mentioned is xbox music, which is about half a million lines of typescript. In addition the IE11 debugger also is written in typescript.
Re:Announcing TypeScript 0.9.1 by HarshaThota on Tuesday August 06, 2013 @11:22PM (#6170633)
The TFS web UI is another project that was converted to Typescript.

http://blogs.msdn.com/b/bharry/archive/2012/10/24/typescript...

Re:Announcing TypeScript 0.9.1 by sequence7 on Wednesday August 07, 2013 @04:21AM (#6171520)
Also the Azure management portal is written in typescript.
Re:Announcing TypeScript 0.9.1 by jol on Wednesday August 07, 2013 @04:17AM (#6171502)
I'm just starting with some hobby project (as usual nothing special to show yet) and picked up typescript as it supports me when I am forgetful (as the project time is scattered in small bits) or just plain lazy. I see this as big win for big projects where no-one (or at least no-one) can see all the details in the project, it saves a lot of jumping around in codebase
Re:Announcing TypeScript 0.9.1 by johnny_reilly on Wednesday August 07, 2013 @06:30AM (#6171857)
I started using it just to see what the experience was like. My conclusion is that it's brilliant. It makes refactoring a much speedier experience which you can now do without the fear that you might with a straight JS codebase.

A real aid to productivity in my opinion. And I love how you can turn up and down the typing as you see fit.

Re:Announcing TypeScript 0.9.1 by janekk on Wednesday August 07, 2013 @08:59AM (#6172462)
Yes, ~38,000 lines of TypeScript for my app (https://www.datacracker.com/).

The benefits of inferred typing is great. Mostly you just need to explicitly declare the types of your class properties, and then code that uses the properties or modifies them (like .map() or .forEach) doesn't need explicit types defined - so it still looks like JavaScript.

Refactoring is no longer a search and replace in files (and pray tests pass) affair.

Dealing with other programmer's code is no longer as mentally taxing.

Re:Announcing TypeScript 0.9.1 by jinder on Wednesday August 07, 2013 @08:39AM (#6172343)
We built Kangaroom (http://kangaroom.co.uk/) entirely using TypeScript. There are tens of thousands of lines of code.

The optional typing ability is a life saver when your code base grows. We've used the integrated tooling with Visual Studio which also helped a lot.

Microsoft is promising it will be kept in sync with ECMAScript 6, so we don't really think there is much risk in using it. It's definitely helped with productivity, and the learning curve isn't high for JavaScript developers.

Re:Announcing TypeScript 0.9.1 by particlewave on Tuesday August 06, 2013 @10:08PM (#6170404)
Yes, using it, large project. TypeScript + Webstorm is very productive.
Re:Announcing TypeScript 0.9.1 by robin_reala on Wednesday August 07, 2013 @02:18AM (#6171187)
Turbulenz migrated their WebGL game engine / platform over to TypeScript and seem pretty happy with it.
Re:Announcing TypeScript 0.9.1 by cangencer on Wednesday August 07, 2013 @04:24AM (#6171527)
has anybody been it using it for a node.js project? (i.e. serverside?)
Re:Announcing TypeScript 0.9.1 by subsection1h on Wednesday August 07, 2013 @07:16PM (#6176311)
To anyone wondering, every site that was linked to as response to the parent comment was built with ASP.NET.