Sunday, June 30, 2013

TypeScript lambda expression

In my opinion, TypeScript is the best solution for MS/.NET oriented development.

At first - it is very similar to C#, that makes .NET developer's life easy.

At second - TypeScript is a superset of JavaScript, and you can mix "pure" JavaScript code with "typed" TypeScript. It is very important in case you have a lot of JavaScript in your project and want to take advantage of modern web technologies. I have an example - my IZWebFileManager project

At third (but not less important) - it has Lambda expression

I am using JQuery AJAX, and used to write such code:



It is simple closure, that I use to keep reference to the instance that I work with from ajax callback.
This pattern became routine and very annoying.

But TypeScript bring the solution:


It is much simple, no need to care of what 'this' is anymore. It just does all this annoying routine behind the scene. There is compiled JavaScript output:



It worth to move to TypeScript just because it is a great feature