Live data from Hacker News

TS to JSDoc Conversion

github.com

21–30 of 163 posts

Re: TS to JSDoc Conversion

#21

Why would anyone do this?

10 years ago I have used Closure compiler from Google, https://github.com/google/closure-compiler/wiki/Annotating-T... , as a type checker. We had to use for production a different minimizer, not the closure compiler, but it was extremely useful to check for types and JSDoc-style annotations were very readable with minimal distraction.

Flow for JS from Facebook also supports types-as-comments, https://flow.org/en/docs/types/comments/ , but those are rather ugly as one has to intermix them with JS rather than using separated comment block on top.

Re: TS to JSDoc Conversion

#22
post #19

If I remember right, symfony (php framework) has comments that affect how the code runs which as far as I’m concerned means they’re not comments at all but actually code masquerading as comments. Reading about JSDoc gives me the same uneasy feeling, even if it’s not quite the same thing. Edit: Here’s one example, you can define your routes in symfony using comments. Not only that, but it’s actually the officially rec…

where does it say that JSDoc has runtime implications?

Re: TS to JSDoc Conversion

#23
post #9
post #6

Earlier quoted context omitted.

To keep the benefits of Types w/o the burden of TS.

with the difference that typescript generates the types automatically or at least tries to and in JSDoc the user needs to write the JSDoc. Edit, btw: Most complex types in the MR are now completly broken. It's crazy that there is a serious project out there who tries to mix jsdoc and typescript interfaces in the same project. it's like getting bad things from two worlds.

Just add some interfaces.d.ts and import those types into jsdoc and you still have all your complexity

Re: TS to JSDoc Conversion

#25
For anyone who is still confused - they're still gonna be using TypeScript in that they will have a tsconfig.json, `allowJS: true, checkJS: true` but they are just writing the files in JS with JSDoc type annotations, they'll still have `.d.ts` files to allow TS developers to use it without issues.

Is it contrarian - yes - is it insane - no, not really.

Edit: the motivation seems to be to simplify processes - running TS files can be awkward, and cross importing is awkward. fwiw created my own tool for this ([url-redacted])

Re: TS to JSDoc Conversion

#26
We do this at my current company for all projects, it does not mean you don't use typescript, you will still validate all your files with TS, but there's no build step, just a check.

Very rarely we find a case that we can't cover with JSDoc annotations, and most of the time it means the code could be refactored to be simpler.

I do this now for all my personal projects, in my opinion it's simpler, faster and closer to pure JS.

Re: TS to JSDoc Conversion

#27
post #9
post #6

Earlier quoted context omitted.

To keep the benefits of Types w/o the burden of TS.

with the difference that typescript generates the types automatically or at least tries to and in JSDoc the user needs to write the JSDoc. Edit, btw: Most complex types in the MR are now completly broken. It's crazy that there is a serious project out there who tries to mix jsdoc and typescript interfaces in the same project. it's like getting bad things from two worlds.

With modern IDE writing JSDoc comments is a fast process

Re: TS to JSDoc Conversion

#28
post #19

If I remember right, symfony (php framework) has comments that affect how the code runs which as far as I’m concerned means they’re not comments at all but actually code masquerading as comments. Reading about JSDoc gives me the same uneasy feeling, even if it’s not quite the same thing. Edit: Here’s one example, you can define your routes in symfony using comments. Not only that, but it’s actually the officially rec…

where does it say that JSDoc has runtime implications?

It doesn’t and I say in my comment that it is not the same thing. Nevertheless it gives me the same uneasy feeling because you don’t know what features are going to creep into the language further down the road.

Re: TS to JSDoc Conversion

#29
post #25

For anyone who is still confused - they're still gonna be using TypeScript in that they will have a tsconfig.json, `allowJS: true, checkJS: true` but they are just writing the files in JS with JSDoc type annotations, they'll still have `.d.ts` files to allow TS developers to use it without issues. Is it contrarian - yes - is it insane - no, not really. Edit: the motivation seems to be to simplify processes - running…

TS can generate d.ts files from JS files that use JSDoc

Re: TS to JSDoc Conversion

#30
Finally things are heading in the right direction. Can't wait for more to do this. Typescript might be good for some, but I'm glad to see the hype finally begin to fade, so the rest of up can breathe again.
Post reply on HN