Hacker News new | ask | show | jobs
by jsynowiec 3437 days ago
Re 1: This is not a problem with TypeScript, but with Node. It's the same with every to-js-transpiled language. You can use https://github.com/evanw/node-source-map-support to get stack traces for your TS sources.

Re 2: I do agree that this is a problem but remember that it's all just a community effort. You can always create your own type definitions or enhance existing ones and share on the DefinitelyTyped repository. Also, most of the time if a type definition is out of date or invalid, you can just create your own partial typedef for a module with only those several methods you are actually using.

Re 3: IMO it's a feature. By using, for e.g. a bluebird library to wrap third party code in a Promise, you are changing the way how your code is interacting with that library by redeclaring the whole library or some parts of it. TSC is complaining because you've changed the declarations. You have to provide your own type definitions, either inline, or for the whole module.

I've engineered or reviewed several projects that are using TypeScript with success. The teams after initial hiccups are mostly not willing to come back to pure JavaScript now.

I'm not advocating to use TS everywhere and for every project. It all depends. Many factors must be considered but some sort of type checking is usually a good thing to have.

1 comments

Yea, I didn't really mean for my comment to be a criticism of Typescript itself, but rather I wanted to explain some of the difficulties I have encountered trying to use it on a large node project.

Per your follow-up comments:

1. Have you gotten node-source-map-support to work with a logging framework like Winston that handles uncaught exceptions? It didn't work out of the box for me, but I'm sure that with some effort it could be made to work.

2. Yea. I think a big part of the problem is that even a lot of very popular node libraries just aren't that stable. APIs change a lot and the documentation is poor, so keeping a type definition up-to-date and accurate is particularly difficult.

3. I agree that that is by design, but that doesn't make it any less of a barrier to using promises across an application that depends on a lot of 3rd party libraries, and as a developer I don't want to have to spend a lot of my time maintaining type definitions to work around it in my project.

I agree that having used Typescript I would not want to move back to plain JS, but for me the experience pushed me away from using node as a backend in the future, as I think there are other platforms that provide the same benefits without the drawbacks and difficulties.

I am just curious, which platforms do you think provide the same benefits without the drawbacks ?