-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
TS and node16 modules #891
Comments
I expect this will break with a lot of npm packages. Weird decision of the TypeScript team to define that option in such a way that it doesn't work with the way most packages are being published (single declaration file using ES exports). Does anybody know about a non-invasive way around this (that doesn't break with the old resolution setting)? |
I had similar troubles with types not recognised on "strict" mode on TS 4.7, similar to here, and in the end we found that // package.json
{
"name": "@codemirror/view",
"type": "module",
"exports": {
"types": "./dist/index.d.ts", // <-- add this, notice the dot-slash, also the position is important
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"types": "dist/index.d.ts" // <-- still keep, notice no dot in front
} I updated all my open source npm packages that way. |
Here's a bit more context as well: microsoft/TypeScript#49160 (comment) I'm eager to see this fixed, so I would be happy to take a stab at it. |
I have an open PR for this in |
I think this should be fixed since June now. |
Codemirror does not compile with typescript 4.7 when
"module": "node16"
and"moduleResolution": "node16"
in the tsconfig. Error:Why
In a few words, TS introduced new ways to publish and consume type definitions and TS files depending on if you code using ESM or Commonjs.
What I tried to fix it
According to this, adding an
index.d.cts
does the trick. So I copy-pasted theindex.d.ts
and renamed it. Then I removedtypes
from thepackage.json
and it did not work.Also
The same issue seems to affect other packages as well:
@codemirror/view
@codemirror/state
@codemirror/lang-markdown
Context
16.2.0
codemirror
6.0.1@codemirror/lang-markdown
6.0.0The text was updated successfully, but these errors were encountered: