Live data from Hacker News

JavaScript libraries should be written in TypeScript

staltz.com

1–10 of 285 posts

Re: JavaScript libraries should be written in TypeScript

#2
The title is needlessly inflammatory (hope that's the right word). It's the original one, but the article states clearly that it is an advice for libraries that are intended to be used by thousands of developers. Maybe the title could be changed to "All big JavaScript libraries…"?

Re: JavaScript libraries should be written in TypeScript

#3
post #2

The title is needlessly inflammatory (hope that's the right word). It's the original one, but the article states clearly that it is an advice for libraries that are intended to be used by thousands of developers . Maybe the title could be changed to "All big JavaScript libraries…"?

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

Re: JavaScript libraries should be written in TypeScript

#4
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.

Re: JavaScript libraries should be written in TypeScript

#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...

Re: JavaScript libraries should be written in TypeScript

#7
post #3
post #2

The title is needlessly inflammatory (hope that's the right word). It's the original one, but the article states clearly that it is an advice for libraries that are intended to be used by thousands of developers . Maybe the title could be changed to "All big JavaScript libraries…"?

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.

Re: JavaScript libraries should be written in TypeScript

#8
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.

You may or not be right, but Typescript seems to be gaining a reasonable amount of attention and traction outside Microsoft, so I suspect its type system may be "good enough" to add a decent degree of type safety while still staying close enough (for better or for worse) to vanilla Javascript that developers, CTOs, etc. aren't put off by the perceived difficulty/risk of a totally new language (also I guess the Microsoft backing counts for something).

There are enhancements to the type system on the roadmap, for example support for non-nullable and variadic types: https://github.com/Microsoft/TypeScript/wiki/Roadmap

Typescript may not be perfect but I'm glad to see it getting more attention as I think it can bring a significant quality improvement to a code base for a fairly small investment of effort.

Re: JavaScript libraries should be written in TypeScript

#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.

Re: JavaScript libraries should be written in TypeScript

#10
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.

It already appeared, and is called Purescript. It's great, and it's about as likely to gain traction as Haskell.
Post reply on HN