logoalt Hacker News

epolanskilast Sunday at 9:39 PM2 repliesview on HN

Not really, at best it's a verbose and limited subset.

https://github.com/tc39/proposal-type-annotations?tab=readme...


Replies

culilast Sunday at 10:38 PM

It's certainly more verbose but certainly not a limited subset. You can copy paste any typescript Type or Interface in a jsdoc @typedef. As I stated in the article, it's still the TypeScript language service that's analyzing either JSDoc-defined types or TypeScript defined types. It's typescript all the way down

But JSDoc lets you do pretty much everything that isn't a runtime feature of TypeScript (e.g. enums, namespaces, etc). Even generic slots are supported

show 1 reply
efortislast Sunday at 10:33 PM

Although it's more verbose, it makes code less dense because it lives outside the function parameters.

Also, it's not a super limited subset. For instance, you can write types in .d.ts the IDE uses those types in jsdoc out of the box.

show 1 reply