DEV Community

Discussion on: Why Beginners CRUSH IT with TypeScript

Collapse
 
pengeszikra profile image
Peter Vivo

Typescript is not bad at the end but JSDoc is fare more versatile, compatible with TS, even use TS types from TS module, but can work without compiling. JSDoc vs TS

Collapse
 
asmyshlyaev177 profile image
Alex

JSDoc can't enforce type checks like TS, without enforcing half of the team won't care.
Bigger the team - more benefits from Typescript.
I used to be a TS hater and advocated for JSDoc once.

Collapse
 
pengeszikra profile image
Peter Vivo

JSDoc can also configure to force type check, without extra // @ts-check

Thread Thread
 
asmyshlyaev177 profile image
Alex • Edited

With tsc ? No, thanks, JSDoc is for documentation, can put examples and links there.

Can't put more or less complex types in JSDoc btw, generics for example, maybe on closure compiler only, debug types also harder.

Thread Thread
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

JsDoc can’t replace TS and using it with TS is just great for big teams

Thread Thread
 
pengeszikra profile image
Peter Vivo

JSDoc can use all complex type solution, even generic: (take look this npm module, written in JSDoc)[npmjs.com/package/jsdoc-duck]

Thread Thread
 
asmyshlyaev177 profile image
Alex • Edited

Less than 100 LOC, and seems like nobody uses it. Not a good example.

Types will never be fully properly supported in JSDoc.
github.com/microsoft/TypeScript/is...
github.com/microsoft/TypeScript/is...

I tried to use JSDoc for types myself, it's a pain, and no benefits, way worse than Typescript.
But good to put usage examples and link to docs there

Image description

Thread Thread
 
pengeszikra profile image
Peter Vivo

Thx for your comments.
I brought to table that npm module, because a first I created a good reason - make a useReducer typesafe and easier handle. I don't beleive a too many code lines if problem can be solved a much lighter way.
Main reasion this npm module is proof the JSDoc Generic working perfect and make a life easier.

user declared actions union types -> jsdoc-duck -> typed: [state, action functions]
Enter fullscreen mode Exit fullscreen mode

I even know hard to argue the typesafe useReducer is a valuable stuff, or even hard to argue react is neccecary framework for so many project, currently I try explore the pure html development instead using any freamwork - that why don't spend time to improve that library.

On pure html the JSDoc also hyper helpfull.

Thread Thread
 
asmyshlyaev177 profile image
Alex

Reinventing the wheel every time is a bad idea. Way easier when you have framework/tool and documentation with stack overflow answers.
You will get it if you work on a bigger project with many people.

Thread Thread
 
pengeszikra profile image
Peter Vivo • Edited

Good advice. Maybe easier way still exist, maybe sometimes worth to try another way. I am work on a bigger project with many people ( bit legacy react stuff - 3-7yeard old code ). This is push me to JSDoc direction, because in this project we don't have option to rewrite a full code to TS.

Pure HTML way comming: our deployment process is painfull slow on AWS, so I trying what is the difference between no build, no compile, no framework coding vs. standard framework using. And my first impression is surprising fine, like the lost your chain. ( dependency chain )

Thread Thread
 
asmyshlyaev177 profile image
Alex

Can enable allowJs and start rewriting file by file, obstacle if it is management decision.

I remember how Frontend development started, it was pure JS + JQuery, no frameworks. People started to invent things, it was so messy that can't possibly figure out somebody else code if everything written from scratch. That how frameworks got popular. Frameworks gives solution to very common tasks and make code somehow readable.
AWS is a problem, builders are fine, things like Vite at least fast enough, only Next.js still slow af.

Collapse
 
thesohailjafri profile image
Sohail SJ | TheZenLabs

Actually JSDoc is great option if you want suggestions without committing to ts and its sometimes complicated type errors. I do use JSDoc in Ts or Js project for documentations of helpers and utilities