You probably heard of this new language on top of Javascript called TypeScript. TypeScript promises to make your code better and maintainable by adding more features on top of Javascript such as types and classes.

Javascript purists on the other hand, don’t want types and infer that it is one of Javascripts strengths. That is correct, although if you used a popular open source Javascript library in the past few years, you might’ve come across some documentation that looks like this.

facebook code example

Now, if you looked at the documentation, look at that! You see types! Isn’t that ironic. So you have been using types all along, you just didn’t notice it yet. This pattern is actually used by a lot of big Javascript libraries like Facebook’s JS SDK, Yahoo’s YUI, and many more.

I have been using TypeScript myself lately. And I’m all for it. It makes your code much more readable, and eliminates some boiler plate code checking, like checking for default values and types.

The best thing I like about it is that if you are working on a huge codebase, it would be easier to work with the code by knowing which code breaks because of the compiler, not that we’re all dependent on it, but I wouldn’t mind having some type of checking.

So there you have it, I think TypeScript has a lot of potential. Especially for people who write libraries. If you use Javascript, you might as well use TypeScript.

Discuss on hacker news.