Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why js instead of ts? #338

Closed
tonyxiao opened this issue Dec 11, 2023 · 3 comments
Closed

Why js instead of ts? #338

tonyxiao opened this issue Dec 11, 2023 · 3 comments

Comments

@tonyxiao
Copy link

Would love to hear your thoughts on writing this project in js (with types as comments) rather than ts. Is it to simplify the publishing pipeline or is there something else?

@jaydenseric
Copy link
Owner

jaydenseric commented Apr 7, 2024

Sorry for the late reply.

One day I will write a detailed article to link people too whenever this topic comes up. Over the years I've made lots of detailed comments in various repos explaining why (e.g. jaydenseric/graphql-upload#282 (comment)), but it's not easy to dig them all up as a reference.

Of the many advantages, these ones stand out:

  1. No build step. Being able to directly edit and format the published modules is a fantastic simplification.
  2. The types are shipped inline within the published module. In Deno for example, when you import the module via a URL type safety just works without having to tell Deno to go get definitions over the network from a different URL.
  3. When users in their editor CMD+click on exported things of this package in their code, it takes them directly to the real code they are using instead of off to a seperate TS definitions file that doesn't contain the actual code. This is a great DX improvement.
  4. Significantly less bloated node_modules because you are not doubling the amount of files by having a companion .d.mts file for every .mjs file.

@jaydenseric jaydenseric closed this as not planned Won't fix, can't repro, duplicate, stale Apr 7, 2024
@tonyxiao
Copy link
Author

tonyxiao commented Apr 7, 2024

  1. can be solved by publishing the source, but that worsens 4) because you'd be publishing 3x, the js code, the d.ts code AND the ts code. That's what I'm doing now though.

if only all js runtime support ts by default for future...

@tonyxiao
Copy link
Author

tonyxiao commented Apr 7, 2024

Great reasons though, thanks for writing it up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants