Remix.run Logo
zackify 2 days ago

5 years ago I was at a meet up and the guy talking was saying how if you don't like typescript these jsdocs are the way to go. Had to explain to my employer attending that it is still typescript. Didn't seem to believe me and was super against typescript but not jsdocs lol

sntxcmp 2 days ago | parent | next [-]

The difference is syntax compression imo.

TheRealPomax a day ago | parent | prev [-]

> Had to explain to my employer attending that it is still typescript

"is" is doing a lot of heavy lifting there: JSDoc and TypeScript are two different ways to explicit prescribe typing in a way that tooling can use to determine correctness. The TS syntax is _far_ more powerful, but JSDoc can do most of the common TS use cases, for folks who want to stay in JS land while still benefiting from type tooling (either invoked or straight up built into the IDE).

culi a day ago | parent | next [-]

> in a way that tooling can use to determine correctness.

As I pointed out in the article, the "tooling" is exactly TypeScript language services. If you are using JSDoc and you get squigglies or intellisense or any other similar features, you are using TypeScript.

You can copy-paste basically any bit of TypeScript into a JSDoc comment and it will work. JSDoc supports any non-runtime feature of TypeScript (so not enums). Even generics! You can even reference TypeScript utility types!

The whole point of this article was to correct the idea that JSDoc is not TypeScript. It absolutely is! There's almost nothing you can't define in JSDoc that you can't define in a .ts file. Albeit with a sometimes clunkier syntax

anovick a day ago | parent | next [-]

That's absurd.

JSDoc is a comment formatting standard.

The tooling used to parse it is independent.

In the same vein, a file of ISO C++ (take any version) code is not "GNU C++".

matt_kantor 16 hours ago | parent [-]

By "JSDoc is TypeScript", culi means "JSDoc syntax and TypeScript syntax are two alternative ways to describe types to the TypeScript compiler/language services, and the two syntaxes have nearly-identical expressive power".

anovick 10 minutes ago | parent [-]

I understood it that way too. Only that it fails in that interpretation.

Just because currently the most popular method for parsing JSDoc utilizes TypeScript-related tooling doesn't mean we should associate them with each other.

To my previous example, an ISO C++ can be compiled by GCC but also can be compiled by Clang (and many other compilers).

KPGv2 a day ago | parent | prev [-]

> If you are using JSDoc and you get squigglies or intellisense or any other similar features, you are using TypeScript.

This is true in the same way you are "using" C++ if you are on Windows. When most people say "use XYZ language" they mean "are personally writing code in XYZ language" rather than "under the hood my code is transpiled to this other language I don't write in"

Sammi a day ago | parent | prev [-]

In practice today JSDoc 100% completely and utterly always is Typescript.

It might not have been so originally. It might still be possible to do differently. But in practice today you are getting Typescript in your JSDoc with the out of the box tooling that is everywhere.