TypeScript - a way to embrace the fuzzy world of java script.
By Mirek on (tags: javascript, TypeScript, categories: architecture)What I always dislike in java script was the fuzziness of this language. Very often you didn’t know what type the variable is or if it was an object or a function. I always lack of some strong typing, design time rich intellisense or compile time type checking, which would minimize the possibility of making a bug in the java script code.
TypeScript is a cure for all inconveniences of java script language. It allows static typing, class-based object oriented programing,interfaces declarations, generics and many more. It also has modules which is is similar to c# namespaces. Type script is a superset of java script language so the syntax is mostly the same. That also means that every java script code is already a valid TypeScript code. The cool feature that comes with TypeScript is intellisense and type checking at compile time thanks to tooling addons in Visual Studio. That is possible since TypeScript supports static typing. However to have that available for each java script library like JQuery we must include in the project so called declaration files (extension .d.ts) which basically contain interfaces to compiled java script code. Declaration files for many java script libraries are already available as nuget packages. Another advantage of TypeScript tooling in VS is a possibility to debug your TypeScript in the same way as c# code, from vs debuger, with all benefits that comes with it. That includes examining variable values, setting breakpoints, watches, call stack and so on. All those features should make our work with javascript code as easy as with normal c# code. This is just a short introduction, for more info, tutorials, samples and playground environments go to this website.