Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To add to what everyone else is saying: I started using TS back in the 0.8 days, before generics were a thing. Since then, I have built several projects with TypeScript and migrated one JavaScript project to TS. These projects also involved Knockout, WebSQL, jQuery and other extras. Along the way, I got most of my colleagues hooked as well. When a new project starts up, the question is usually " Is there a compelling reason to use plain JavaScript instead of TypeScript here? ", not the other way around.

The good parts :

* The type system serves as a great safety net and prevents a whole class of bugs.

* Intellisense is far smarter than you would get from JavaScript (no more silly IDEs with both jQuery's .append() and DOM's .appendChild() in the same intellisense suggestion). This enables refactorings and intelligent assistance such as Find All References, which is much more brittle in plain JS.

* Classes are much more convenient and readable than old-school inheritance solutions. Those old solutions were also a huge problem for JS intellisense.

* AMD Modules paired with Require.js are much more centralized than "add these fifty script tags to the HTML document, in the right order". That's more due to AMD, but TypeScript adds some nice syntax sugar on top of that.

* Arrow functions. No more `var that = this` to keep callbacks working.

* Generics, function overloads, etc. - depends on the things you use in your code. If most of your viewmodel properties are Knockout Observables, generics are a life saver. If you're chaining Promises, again, generics can cover their return/param types. Function overloads come in handy if you have factories building objects based on string parameters (example: document.createElement() returns different classes based on the name passed in). And so on.

The bad parts :

* New language to learn. And it keeps evolving.

* Requires an additional build step. There's a large amount of small projects without any build process out there - integrating TS into such a project can be difficult and open a new can of worms related more to the build process than TS (e.g. "do you commit the generated JS and sourcemaps, or provision a build server to package them?"). Of course, if you're already using Grunt/Ant/Phing/whatever else, this is not a big problem. (You should be using a build process at least to aggregate your JS into one blob, if nothing else.)

* Definitions for third-party libraries. DefinitelyTyped helps a lot here, but there are still things that it doesn't cover, and it can be time-consuming to keep a definition file in sync with a library as the library updates.

* IDE support. After using PHPStorm/IntelliJ and Visual Studio Express/Community, Visual Studio wins hands down. IntelliJ's support was quite disappointing and glitchy, especially its lack of intellisense. Visual Studio Code, Community and Express are all free, but the latter two are quite bulky and running them alongside a different IDE can be slow.

* Debugging can be a bit challenging due to sourcemaps, depending on the target browser. I prefer to disable sourcemaps and debug the generated JS directly, but that requires some mental juggling and is not everyone's cup of tea.



> New language to learn. And it keeps evolving.

A lot of the “new language” parts is ES6, stuff that will be becoming more commonly used soon and which there is value in. The parts that are actually TypeScript itself are very much more restricted and really are just bits around the type system.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: