DEV Community

Cover image for What is JSDoc and why you may not need typescript for your next project?

What is JSDoc and why you may not need typescript for your next project?

Cherry Ramatis on January 23, 2024

It has been a couple of weeks since I started testing out this technology, JSDoc, for maintaining some JavaScript codebases. This has been especial...
Collapse
 
brense profile image
Rense Bakker

primarily with the argument that "removing typescript is the same as removing types"

That's not really true. Ignoring all the uninformed anti/pro trolls for a second. The main argument was: "why even???" And the main reasoning was: "muh compile time bruh" which is a dishonest argument, because you're not doing tsc at every hot reload, infact you only do it when building and then it takes all of 5 seconds for a million line project, which is really peanuts compared to the time it takes to run a bundler on the same project (yes I'm conveniently ignoring people who don't have any compile step in their project).

And the 2nd main reasoning was: "we are a community project and not everyone in the community knows typescript" which I could partially understand, if you don't follow it up with "let's use jsdoc for typing!" Which is really the same as tsconfig strict = false.

And if you don't use either then yes, you are removing all types and yes I'm strongly convinced that is bad.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Ignoring all the uninformed anti/pro trolls for a second.
[...]
and yes I'm strongly convinced that is bad.

It does come across as a bit dishonest to dismiss people mostly arguing from personal preference as uninformed trolls only to then go on to simply assert an opinion like that.

Maybe you can point out some actual trolls that I'm just not seeing in this discussion, but from what I see both here in this comment section and more widely the discussion around typescript is that most people simply prefer to code either with or without types.

It also seems a bit condescending to imply that the only reason someone might not prefer typescript is that they don't know typescript. Some people just don't like types, and that's okay.

Collapse
 
brense profile image
Rense Bakker

So basically you agree. It boils down to whether you think a type system is important or not. All other arguments that people use to hate on typescript are basically nonsense.

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

No. It boils down to whether you think the value of a type system outweighs the problems it brings. Both are relevant questions; if you think the value it adds is low, smaller nitpicks will be what keeps you from using it. Pretending any of these problems are "nonsense" is little more than arrogance.

Arguments like "but it requires an extra build step" may not amount to much if you see immense value in a type system. But for someone to whom types aren't of much importance, that is a very good reason to just use plain JS.

It's like picking up an apple and finding a worm inside. If you're starving, you might think that's a dumb reason not to eat it. If you aren't hungry and don't even like apples, it's a very good reason to just throw it away and eat a donut instead.

Thread Thread
 
brense profile image
Rense Bakker

But it doesn't require an extra build step during development. There is no worm and donuts are bad for your health =p

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Browsers running typescript directly is news to me

Thread Thread
 
brense profile image
Rense Bakker

Your dev server that serves your static files to the browser does. It's because of the fact that typescript is a superset of JavaScript, meaning, when you omit the types, its just JavaScript and your dev server can do that omission during transpilation, without extra overhead. Also if you did actually compile the typescript, it's also only compiling files that have actually changed and even if you compiled from scratch that typically only takes a few miliseconds as well. Minifying your JavaScript for production takes way longer.

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

...so a build step then? I rest my case.

Thread Thread
 
brense profile image
Rense Bakker

No build step during development. I rest my case, you're deliberately trying to spin things to fit your own narrative, which is based on deep hatred, instead of actual arguments.

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Honestly, I don't want to have a discussion with someone who gets this emotional over a programming language. Have a nice day.

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

I feel grumpy that this is still an issue in 2024 whether and how to do types.
Static types are a foundational feature of not only modern programming, but also ancient programming. Great programming hero Tony Hoare invented them in 1965. Yes, you have read that right.

It is really unfortunate that the design of JavaScript was rushed in ten days in order to be ready for Netscape 1.0. The current mess where people argue over typescript and jsdoc and vanilla javascript all comes from trying to fix things after that unfortunate fact.

My real point is that types should be a "Don't Make Me Think" issue.

Collapse
 
cherryramatis profile image
Cherry Ramatis

Types are great, I love types, but Typescript trade-offs are not only having types vs not having types

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

Yes you are right and I understand.
What I am saying that there should be no tradeoff.
It's a strange story without anyone being bad or wrong about anything.

I imagine a world where Netscape would have decided to wait a bit and polish JavaScript before releasing it for Netscape 1.0 and make upgrading it very difficult, so difficult that even the best can't do it right.
In this world, there would have not been drawbacks for Netscape because while JavaScript was pretty much useless at the time of Netscape 1.0. Gmail the first impressive Javascript app is from 2003, way after that.
JavaScript was useful only for marketing purpose at that time, but they got the marketing wrong, they called it Java something because Java was the hype new language of the internet.
Young recruiters wouldn't make the obvious rookie mistake of not thinking that two languages that have a very similar name have nothing to do with each other.

Netscape and Brendan Eich would have had time to polish its rough edges.
Douglas Crockford wouldn't have had to write "JavaScript the good parts" with his last chapters about bad and horrible parts that would mostly not exist.
Everyone else would not have had had to fight so much to fix one issue of JavaScript after another.
It's impressive the work that the JavaScript has done to overcome all of this, but this would not have been as necessary

And most importantly, countless developers would have had as first language the good parts of this language, but without the bad and awful part.
Right from the start, where it matters most from a pedagogical point of view, they would have had more developer sanity by design.

This word I imagine would have been slightly but meaningfully better

Thread Thread
 
lionelrowe profile image
lionel-rowe

But think about what we would have lost if JS was well-designed. I for one don't want to live in a world where "hello".fixed() didn't equal "<tt>hello</tt>"

Thread Thread
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

I didn't know that, that's super funny <3

Collapse
 
starboysharma profile image
Pankaj Sharma

🌟 Hey there! 🌟

I just want to share my experience with JSDoc 😉

I've started using JSDoc in our legacy project since I can't install TypeScript in my environment. The best part? No need for any third-party package installations! 🎉 Now, we're not just coding; we're also keeping our documentation game strong.

Happy coding everyone! 🚀👩‍💻👨‍💻

Collapse
 
cherryramatis profile image
Cherry Ramatis

Yeah me too, every time i need to maintain an old javascript codebase I just sprinkle a lot of jsdoc and be done with it

Collapse
 
endymion1818 profile image
Ben Read

Same here. In a team where I’m the only JavaScript engineer I have to support the rest of the team who are unfamiliar with a lot of new concepts in JS. JSDoc allows us to get the best of both worlds. Thanks for the article!

Collapse
 
suamirochadev profile image
Suami Rocha

the queen of articles <33

Collapse
 
phenriquesousa profile image
Pedro Henrique

Thanks for sharing ❤️

Collapse
 
kansoldev profile image
Yahaya Oyinkansola

I didn't know about JSDocs, it looks strange to me though, do i need to learn TypeScript in order to use it?

Collapse
 
cherryramatis profile image
Cherry Ramatis

No at all, jsdoc is just a comment pattern that you can use with or without typescript

Collapse
 
clintonrocha98 profile image
Clinton Rocha

Ótimo artigo, será que depois desse artigo a comunidade js/ts vai começar a questionar o uso dessas ferramentas? Seria uma boa hhahahaha

Collapse
 
cherryramatis profile image
Cherry Ramatis

adoraria que começasse daskodasko

Collapse
 
_ndeyefatoudiop profile image
Ndeye Fatou Diop

Great post ! I generally use Typescript and love it! I didn't know you could also use JSDocs this way. Do you also get helpful editor warnings when doing the wrong thing in the editor ?

Collapse
 
cherryramatis profile image
Cherry Ramatis

Yes! with the correct tsconfig (provided on the article) you can get all the feedback from tsserver

Collapse
 
spock123 profile image
Lars Rye Jeppesen

Typescript rocks. Stop being scared of static typings. The days of Perl script kiddies are over

Collapse
 
cherryramatis profile image
Cherry Ramatis

Typescript does rock, the point of the article is literally saying that you can use static typing from the typescript linter + LSP without actually buying the bundle part of the equation :D

Collapse
 
dnnnvx profile image
Marco

I don't understand people complaining about "third party tools", you just have to install typescript, also for the "compile time" there are tools (swc, ...) written in Rust that can compile everything in like... 2 seconds.

I think deciding for JSDoc is useful just for the "writing documentation without even realising it".

I'll try JSDoc at some point, but never had problems with TS since it solves lots of problems. The only thing is that it doesn't make sense in some frontend stuff, like in React, where types are kinda ugly and annoying - imho:

  • JSDoc => scripts / frontend / simple libraries (for docs)
  • Typescript => more complex projects / backend.
Collapse
 
masudalimrancasual profile image
Masud Al Imran

Yeah, no thanks. I will still use typescript on my next projects.

Collapse
 
cherryramatis profile image
Cherry Ramatis

alrighty