News for hackers. Stuff that matters.
Re:JavaScript libraries should be written in TypeScript by Bahamut on Wednesday March 16, 2016 @10:17AM (#11297470)
I don't think you understood the point of the article - it was targeted at library maintainers, not all users.

Types often end up a part of the documentation, and internal typing is often needed in libraries to keep track of model state, so having it at the foundational level in the library itself adds tremendous benefit.

Re:JavaScript libraries should be written in TypeScript by robert_tweed on Wednesday March 16, 2016 @10:28AM (#11297554)
Yes, I don't think I was clear enough but I edited a lot of points out of my post as it was far too long!

The biggest problems in any modern, large-scale JavaScript project are the build process and dependency management. If you are publishing a TypeScript library then it can be consumed either natively as TypeScript, or as ES5.

If it is being consumed as ES5 then your consumers lose most of the benefits of it being in TS. For them to consume it as native TS puts a fairly hefty constraint on their build process, namely that it must go through the TypeScript compiler.

That doesn't negate the internal benefits to your library, but Flow is another option that is a better fit if you are mostly interested in going with the prevailing wind. After all, that was the author's central argument as to why you should choose TS over Flow, and IMO it is quite wrong.

Re:JavaScript libraries should be written in TypeScript by Bahamut on Wednesday March 16, 2016 @10:54AM (#11297786)
The article talks about TypeScript vs. Flow as well - TS has a lot more popularity than Flow currently, and it only looks like the gap is going to grow larger. Types also allows for auto-generation of docs that are guaranteed to reflect the current state of the code.

For a library maintainer, a maintainer can just release an ES5 version of the library when publishing via npm - the user then gets the benefit of choosing between TS or ES5. It can also simultaneously be released as ES6 if desired.

I should mention that it doesn't make sense for pre-existing libraries to migrate to TS (or anything) if it is already in JS and is a largely used library without a specific end goal that is to be achieved - the article is wrong about that, open source doesn't have infinite resources unfortunately.

Re:JavaScript libraries should be written in TypeScript by Eridrus on Wednesday March 16, 2016 @12:08PM (#11298382)
> If it is being consumed as ES5 then your consumers lose most of the benefits of it being in TS. For them to consume it as native TS puts a fairly hefty constraint on their build process, namely that it must go through the TypeScript compiler.

Unless you're making changes to a TS library, there should be no need to build it and you can just use existing the built js files from the library.