Closed dmitrc closed 2 weeks ago
Thanks for sharing this! Have had a few people report it but hadn't look into it deeply yet. We are adding a top level types property, but only when there's a "main" to go with it. I think this problem was introduced when we switched to the "exports" field. I assume you tested this in your local node_modules and it worked?
If you don't mind, could you see if adding a "types": "index.d.ts" also works? I think the types version would apply to the nested paths as well, so would cover all the js, not just the root stuff.
Yup, I tested it locally by making the changes inside node_modules
directly (see screenshots).
As for your proposal, it's my understanding that to make this work you either need to export all the types from the root-level index.d.ts
, or indicate separate type exports (and also import/require as well, I think?) for your non-root exports. Since you're defining a specific export (for .
), it will also apply to the root by definition, not to the nested paths (but I may be wrong).
Unfortunately I won't have more time to try this out until ~weekend. In meanwhile, please feel free to merge the PR I started and experiment on top of that, or abandon it entirely and start a new change encompassing everything. If there was no traction until the weekend, I might stop by to take another look 👍
I think you're right. We do need to do it the way you're proposing since the declaration isn't a rolled up one. I think this means we need an entry "per-export" though
When attempting to use any of the
@ulixee/hero*
packages with TypeScript v5.4.5:Seems like it is easily addressed by additionally specifying
types
in theexports["."]
: