Live data from Hacker News

JavaScript libraries should be written in TypeScript

staltz.com

11–20 of 285 posts

Re: JavaScript libraries should be written in TypeScript

#11
post #7
post #3

Earlier quoted context omitted.

What's a "big" JavaScript library? How do you know how widely adopted your JavaScript library will be?

Regardless, it's difficult to think of any situation where a All _______ should use _______ is really justified.

It works for "people" and "common sense".

Re: JavaScript libraries should be written in TypeScript

#12
post #9

I've recently started using Flow alongside Nuclide IDE (a Facebook-developed suite of Atom extensions), which allows me to easily see the type of a given variable. What's nice is how much types can be inferred from just a handle of type annotations. My editor can start pointing out potential bugs at the cost of relatively little effort on my part, and that's a good place to be.

How are you finding Nuclide? When I tried it a few months ago it seemed pretty slow and unstable, and eventually ended up consistently using all my CPU after a while. There wasn't a great deal of documentation/help setting it up available (true of Flow as well to a lesser extent), which was why I chose TS at the time, but am definitely interested in seeing how Flow is progressing.

I had the same problems when I tried it roughly the same time as you, but I tried it out again this week and it seems to be working much better now.

Re: JavaScript libraries should be written in TypeScript

#14
Starts off with:

> Typed vs dynamic is a rather controversial topic, so I’m not trying to spark that discussion all over again.

Goes on to explain that typed is betterer...

The article doesn't really offer up any real arguments as to why you should specifically use TypeScript, but really just says typed is nice and everyone lints anyway (not true) so the step up to a type system really isn't that big of a deal (also not true.)

Not really sure what point the author is trying to make.

Re: JavaScript libraries should be written in TypeScript

#15
post #5

And then new transpiler language appears, with "real" type system, not java-grade. And everyone stops using typescript, treating it as outdated technology.

One major point of the article is that if such a language appears, the existence of your .d.ts file will make the transition to the new language much easier.

Re: JavaScript libraries should be written in TypeScript

#19
post #6

Or at the very least, library documentation really needs to clearly specify the types of parameters and return values. I'm positively surprised when I come across a JavaScript API whose documentation actually specifies this very basic information. Coming from the static typing world, it's astounding...

+1

Documentation in the web development world is usually very good with the introduction, getting you excited; but terrible when it comes to reference, the day-to-day type docs.

Post reply on HN