Closed
Description
Codemirror does not compile with typescript 4.7 when "module": "node16"
and "moduleResolution": "node16"
in the tsconfig. Error:
some-path/src/code-mirror.tsx(1,40): error TS7016: Could not find a declaration file for module 'codemirror'. '/private/var/tmp/_bazel/198d81e4f6aafdc263b492f2c04a5df7/sandbox/darwin-sandbox/959/execroot/project/node_modules/codemirror/dist/index.cjs' implicitly has an 'any' type.
Try `npm i --save-dev @types/codemirror` if it exists or add a new declaration (.d.ts) file containing `declare module 'codemirror';`
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 the index.d.ts
and renamed it. Then I removed types
from the package.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
- Node
16.2.0
codemirror
6.0.1@codemirror/lang-markdown
6.0.0- Typescript 4.7.2
Metadata
Metadata
Assignees
Labels
No labels