First: no, didn’t create a new framework, so no worries. (JSDocScript isn’t really a thing, I think). Second: just use Typescript! But when you can...
For further actions, you may consider blocking this person and/or reporting abuse
In my experience, JSDoc can't fully replace TS. For quickly check that there are no silly mistakes, you need
tsc
, and JSDoc types quickly become way more cumbersome than TS definitions.But, big advantage of JSDoc is documenting code, surprisingly, can put usage example and link to documentation in it. It is great for reusable code, meanwhile TS good for static checks and IDE autocomplete.
Verbosity aside, there are but a few cases where what you want is to pass generics, but then you have to make some casting that doesn't do what simply passing generics does.
Other than that, jsdoc gives the same static check and IDE autocomplete.
The thing about jsdoc for types is when you have some legacy project that wouldn't support TS otherwise. But for normal "everyday" apps, it's not something you would choose over just using TS.
For libraries, however, I can also see the appeal because it makes debugging and changing the lib far easier. Since you have the code that was written, it's easier to change and then upstream the changes.
Types are most useful with complex cases, e.g. with generics, JSDoc maybe will never get all feature of TS, why MS would do that.
But it does.
I've been using it for almost a couple of years and I can tell you that: as far as typing goes, you can do it with JSDoc. Check the article: dev.to/noriller/jsdoc-101-218c
It's not ergonomic to make some things in JSDoc, so I just make a
d.ts
file for those, but for most things... jsdoc will enable the same types and autocomplete as TS.So, struggle to implement generics and other things, no
tsc
for validation, and manually creatingd.ts
files.It is a thing similar to running Doom on smart toaster, if you can do it, doesn't mean it is a good idea.
But you can run
tsc
on.js
files for validation.And you can also manually create
d.ts
files in normal TS projects.And its less "struggle" and more verbose.
Not to mention. Most cases and projects nowadays start out with TS from day zero. So it's not needed.
Also, most projects are not a lib that might gain from being easy to change the source code.
But, if you are in that few cases it benefits...
You're missing the point.
Most of devs aren't so good and/or motivated, TS let's enforce types check, JSDoc doesn't. Even if you can perfectly live without TS, most of people who will work with your code are not so disciplined to spend more time on verbosity and don't make silly mistakes.
TS benefits teams, that why it get so widely adopted.
Actually you can enforce it.
The point you're missing is that it's not for all projects. But for the ones where you can't use TS (or the even fewer cases where you know you get more from using jsdoc than TS.).
I don't recall any way to enforce types check without TS, something that works only in VSCode won't cut it, need CI/CD as well.
Never seen project when you can't use TS.
tsc
works, you just need to add to check js in tsconfig.it should be enough to show all the errors, but in vscode you might need to turn on a feat, see the other post where I say about it.
and there are legacy code with commonjs where you might be able to do whats needed to work with TS, but depending on the size of the projects it's easier to just use jsdoc instead of nothing at all.
Svelte is leaving TypeScript
I checked it out and I don't know why... they must have their reasons, but it's not something I would do. Typescript is more than just types.
This is certainly something to keep the eye on, thank you for bringing it up!
Hello Handsome
Trying to gather some people doing this here as well: github.com/voxpelli/types-in-js/di...
Nice!