Live data from Hacker News

TS to JSDoc Conversion

github.com

31–40 of 163 posts

Re: TS to JSDoc Conversion

#31
post #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

ty, updated

Re: TS to JSDoc Conversion

#32
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…

Are they not using attributes, which start with a #? I thought PHP had C style // comments.

Re: TS to JSDoc Conversion

#33
post #12
post #5

Earlier quoted context omitted.

ts-node [1]: am i a joke to you? [1] https://www.npmjs.com/package/ts-node

ts-node is responsible for my favourite error message in all of computing. Yes better than: 'Error: success' or 'keyboard not found: press F1 to continue' > ts-node: Unknown file extension: ts. Someone will reply for a technical reason about this (mentioning .mts or package.json settings or whatever) but that doesn't change the fact that a program whose only job is to run ts files should know what a ts file is. GitHu…

I'm glad you mentioned this - I had the exact same issue when using ts-node and it really blew my mind.

Re: TS to JSDoc Conversion

#34
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…

That’s a PHP attribute:

https://php.watch/articles/php-attributes

Re: TS to JSDoc Conversion

#35
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…

I don't see any comments there, I see attributes though [1]. Is that what you meant?

From the page you linked:

> Routes can be configured in YAML, XML, PHP or using attributes. All formats provide the same features and performance, so choose your favorite. Symfony recommends attributes because it's convenient to put the route and controller in the same place.

Attributes are not comments, they are an official structured way of handling metadata.

[1] https://www.php.net/manual/en/language.attributes.overview.p...

Re: TS to JSDoc Conversion

#36
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…

> as I’m concerned means they’re not comments at all

Smuggling pragmas in comment has a long and rich history. It’s literally the reason why json does not support comments.

> Reading about JSDoc gives me the same uneasy feeling, even if it’s not quite the same thing.

It’s not just “not quite the same thing”, it’s entirely unrelated in every way and shape. JSDoc does not affect the runtime behaviour of its code, or how that code interacts with other systems.

Re: TS to JSDoc Conversion

#37
post #7
post #5

Earlier quoted context omitted.

ts-node [1]: am i a joke to you? [1] https://www.npmjs.com/package/ts-node

ts-node does not play well with ESM modules out of the box. I've started experimenting with tsx but it still has some edge cases of its own. Honestly, ESM has been the bane of my existence this year as packages are slowly starting to migrate, and fixing issues lays on the developer, not any one framework.

Overall the shift to ESM has been one hell of a dumpster fire.

And introducing new extensions like .mjs or .cjs is the smoldering dead raccoon responsible for half of the smell.

Re: TS to JSDoc Conversion

#39
post #32
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…

Are they not using attributes, which start with a #? I thought PHP had C style // comments.

They are attributes. PHP does also allow # as a comment character in addition to // style comments and I assume that's where the poster got confused.

Re: TS to JSDoc Conversion

#40

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…

This is great but -if I dare - wouldn't it be time to allow js to have type annotations [1] ? As in python, treat it as comments for now but with real syntax and let interesting dialects emerge from the consensus ? I like jsdoc but the syntax is urgh.

[1] https://github.com/tc39/proposal-type-annotations

Post reply on HN