Join the DZone community and get the full member experience.Join For Free
I have been trying to keep myself out of UI Development for years until recently with the emergence of Microsoft TypeScript. Developing UI elements with TypeScript is such a breeze that I no longer hit my keyboard too hard and my colleagues are no longer afraid to approach my desk during UI development. Most importantly, I spend more time with my family rather than countless late nights in the office trying to solve an unknown mystery.
Here are a couple of reasons that this appeals to me.
Object Oriented Support
One of the main goals of TypeScript is to make it as compatible as possible to ECMAScript 6, hence it supports most (if not all) of the object oriented concepts/constructs, specially classes, interfaces, modules, generics, static typing, etc. The following code snippet demonstrates most of the concepts. It looks more natural and closer to what an object oriented developer would imagine. This is a good point about typescript in that it borrows most of the concepts and syntax from existing languages, hence the educed learning curve.
Most of the IDEs (Eclipse, WebStorm, and Visual Studio) have support for TypeScript, either built in (Visual Studio) or as a plugin. All of which makes life easier since IDE acts as the enforcer and guide developers need.
Build Tool Support
The equivalent TypeScript code would be:
External Library Integration
The million dollar question: What about the external libraries (JQuery, Backbone, Jasmine, AngularJs, etc.)? It can be defined based on the functionality it provides and that is why the Definitely Typed repository exists. If you explore this repository you will find the d.ts for almost everything you can think of. If for some reason it does not exist, it can be created easily.
- CoffeeScript: Neater syntax which is based on other dynamic languages, thereby making it easier to write.
Applications Using TypeScript
- Office365 and Visual Studio Online use TypeScript heavily
- hawtl.io UI is written entirely using TypeScript
This sample Typescript application is loaded with lots of features and basically demonstrates Typescript feature usage in collaboration with existing libraries and tools.
- Module, Classes and Interfaces
- Unit Testing With Mocking and Spying Using Jasmine
- Grunt Usage
- Project directory structure organization
Feel free to clone it and play with it. Instructions are provided in the Github repository.
Opinions expressed by DZone contributors are their own.