← Back to context

Comment by sroussey

15 hours ago

Publishing a lib as JS with .d.ts type files gives you JS compatibility and TS types for using the lib, but no TS source so no types inside.

I’ve seen people want to publish TS libs but there are issues: TS will type check the libs as well as your project. You can’t tell it to stop just because it’s going inside node modules. And the app may have tighter settings than the library and you will get type errors if your configs were setup differently. It would be interesting to standardize publishing real typescript libs but I haven’t seen it. Maybe deno tried? I haven’t looked.

When publishing on jsr.io, you upload the TypeScript, and if using Deno, you also download TypeScript (with import statements rewritten.) Having nearly the original source code is better for debugging.

Deno doesn’t type-check external dependencies unless you ask.

  • With the exports rewritten? Maybe we should have a export of “ts” like we have “types” instead?

    • Not sure what you mean, but to expand on what I wrote, JSR rewrites the import statements to include file extensions and full version numbers for package dependencies, so that the imports can be resolved without looking for them in multiple places.

      There's a way to download JSR packages and use them with npm too. I don't know what it does in that case.