-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
packages provide wrong types under node16 module resolution #1031
Comments
Hi @not-my-profile, Unfortunately this is impossible for us to solve. As package authors we need tools to do this thing :
No such tool exists. You can report this issue either with TypeScript or with Rollup. If however such a tool does exist, please let us know. |
Thanks for the quick reply! I see. Yeah I think this currently hangs at microsoft/TypeScript#54593. |
Hi. I just ran into this issue as well.
I believe |
Hi @CobyPear,
I fear it will be too hard to maintain such a dependency long term. |
@romainmenke I think that's the world we live in right now in the TypeScript/Node ecosystem: pain for the end user because the package emits the wrong stuff, or pain for the maintainer to emit the right stuff. I understand wanting a more robust solution to do this by default but I had thought in the past the TS team said they didn't want to deal with this issue and it was up to the ecosystem to make ESM, CJS, and TypeScript play nicely. I'll keep searching for the issue I'm referring to in the TypeScript repo and post it here if I find it. Maybe all that's needed for your libs is That article mentions the following which may be at play here:
|
I think I currently have a good grasp on the complexity of this issue.
Issues 1-5 are unsolvable by us. But issues 1-5 go away when you stop dual publishing typings. Issue 6 can be solved by bundling types into a single |
node16 from ESM: type errors
Using the packages from Deno with TypeScript leads to type errors, but these errors can also be observed with
tsc
and Node.JS when using the new node16 module resolution:node16 from CJS: runtime error
What to do
As Are the types wrong? explains:
So the
exports
like the following are wrong since they provide onetypes
for both ESM and CJS:postcss-plugins/plugins/postcss-nesting/package.json
Lines 39 to 46 in aaf8807
Unfortunately
@rollup/plugin-typescript
like apparently most other build tools does not supporting correctly emitting different type definitions for ESM and CJS.(Note that the Are the types wrong? website currently wrongly doesn't report the node16 From CJS problem since it doesn't yet perform type checking).
The text was updated successfully, but these errors were encountered: