logoalt Hacker News

paulddraperlast Sunday at 9:19 PM1 replyview on HN

And in fact, this what the Closure Compiler does…typecheck based on JSDoc.

However, the precision and completeness is not nearly what can be expressed in TypeScript. With generics particularly.


Replies

culiyesterday at 12:06 AM

Care to give an example? In another reply I pointed out how advanced JSDoc syntax's support for generics is.[0] Even allowing for `extends` and default values for generic slots.

The clunkiest part is in the way you "pass in" a generic to a slot. But this is solved by typing the return type.

I use generics pretty extensively and I've not yet come across a use-case JSDoc couldn't handle

[0] https://news.ycombinator.com/item?id=46267810

show 1 reply