jsr
jsr copied to clipboard
Using package.json types field for JS packages
I tried to publish a package with a .js file as the entrypoint and received this message:
warning[unsupported-javascript-entrypoint]: used a JavaScript module without type declarations as an entrypoint
--> /home/runner/work/humanfs/humanfs/packages/core/src/index.js
= hint: add a type declaration (d.ts) for the JavaScript module, or rewrite it to TypeScript
info: JavaScript files with no corresponding declaration require type inference to be type checked
info: fast check avoids type inference, so JavaScript entrypoints should be avoided
docs: https://jsr.io/go/slow-type-unsupported-javascript-entrypoint
I generate the .d.ts files in the build step and they-re placed in the dist folder above the source file. I don't want to pollute the source directory with the generated .d.ts files, and my package.json file has a types entry.
Ask
Would it be possible to read package.json (if found) and use the types field to locate the .d.ts files for JavaScript entrypoints? (Instead of requiring them to be next the source files?)
Yes, this is something we'd like to do.