1. Lambdas (as you mentioned) are not only shortened syntax, but also capture the `this` variable automatically for you. Try typing in the following at the playground in the body of the `greet` method to see what I mean (http://typescriptlang.org/playground):
var x = a => this.greet();
2. Classes with inheritance are a big one, implemented using the IIFE pattern as well, with support for static and class members.
3. Interfaces with duck typing are very lightweight and easy to use:
4. Extensive type inference. In the following example, the function greet will be typed () => string:
class Greet {
greet(x: number) {
var s = ' greetings';
return x + s;
}
}
Static and member vars, return types, local variables, all are type inferred.
5. Javascript is TypeScript, just without typing, so converting your codebase is instance, and then you can begin adding type annotations to get more robust checking
It should be pretty straightforward to provide Underscore bindings for TypeScript.
One big difference in the library I was working on is that it is lazy, and modeled after .NETs IEnumerable. Whether this is a good thing or not, I'm not yet sure.
I've made a lazy linq-like library for javascript in the past..
The problem i had was that the native array methods are rather fast while function calls (for moveNext) are quite slow, so i couldn't get a whole lot of speed out of it.
Newer javascript engines might be sufficient to offset that though.
I tried to get around this by creating overloads of almost all methods when you are operating on an array. `each` for instance, has a standard implementation using moveNext, and then an array implementation using a fast for loop. In some cases you could even drop down to native function calls.
I'm getting the impression that TS is avoiding making too many dramatic changes to JS. Functions that return undefined in vanilla JS would suddenly return whatever happened to be the last statement; likely leading to unexpected behavior.
i wonder how hard it would be for their compiler to catch the opposite case, then - a program using the return value of a function without a return statement. i think that was my most common bug when i was doing javascript programming, because all the other languages i was using at the time had implicit returns.