Closed adamretter closed 3 months ago
Have you tried upgrading TypeScript to something more recent? I see you're using 4.6, which is two years old.
@marijnh Thanks for your response. Following your suggestion I just tried again with the newer TypeScript versions:
Unfortunately it makes no difference, and they all fail with the same error as we are seeing with TypeScript 4.6.3 currently.
I experimented with adding some compiler options in our project's tsconfig.json
. The issue only goes away if I set either of the following two options:
"noImplicitAny": false
- https://www.typescriptlang.org/tsconfig#noImplicitAny"skipLibCheck": true
- https://www.typescriptlang.org/tsconfig#skipLibCheckObviously neither of these options are particularly desirable in a TypeScript project as they loosen the type checking performed by the compiler.
I note that whilst the prosemirror-commands
, prosemirror-history
, prosemirror-keymap
, prosemirror-menu
, and prosemirror-view
modules all have an dist/index.d.ts
file, there is NO such index.d.ts
file in the prosemirror-state
or prosemirror-transform
modules. Does that mean that perhaps the TypeScript compiler is correct, and that these declarations are missing from some ProseMirror modules?
That seems unlikely, if you really have prosemirror-state version 1.4.3.
> npm i prosemirror-state
added 5 packages in 296ms
> npm ls
tmp@ /home/marijn/tmp
└── prosemirror-state@1.4.3
> ls node_modules/prosemirror-state/dist
index.cjs index.d.cts index.d.ts index.js
Thanks for that insight @marijnh, we are using Yarn instead of npm, but I was able to re-produce your results using the equivalent commands; that is reassuring!
This has given me something to go on though... I note that if I run the following:
nvm use 20
cd /tmp
git clone https://github.com/evolvedbinary/prosemirror-jdita.git test1
cd test1
git checkout test/unit-test-prosemirror
yarn install
Then after that there are these two folders:
/tmp/test1/node_modules/prosemirror-state/dist
:
tree node_modules/prosemirror-state/dist
node_modules/prosemirror-state/dist
├── index.es.js
├── index.es.js.map
├── index.js
└── index.js.map
/tmp/test1/prosemirror-jdita/node_modules/prosemirror-state/dist
:
$ tree prosemirror-jdita/node_modules/prosemirror-state/dist
prosemirror-jdita/node_modules/prosemirror-state/dist
├── index.cjs
├── index.d.cts
├── index.d.ts
└── index.js
NOTE: Only one of those two folders contains the index.d.ts
file!
If I then run yarn build
we again see messages like:
../node_modules/prosemirror-commands/dist/index.d.ts:2:25 - error TS7016: Could not find a declaration file for module 'prosemirror-state'. '/private/tmp/test1/node_modules/prosemirror-state/dist/index.js' implicitly has an 'any' type.
If the 'prosemirror-state' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'prosemirror-state';`
2 import { Command } from 'prosemirror-state';
~~~~~~~~~~~~~~~~~~~
The fact that there is a ../
at the start of the error message, makes me think it is incorrectly looking in /tmp/test1/node_modules
and not /tmp/test1/prosemirror-jdita/node_modules
. This could perhaps explain why it can't find the prosemirror-state/dist/index.d.ts
file I guess?!?
So at this point I am wondering if there is something screwed up about our build settings in package.json
and/or tsconfig.json
. Let me talk to the team, investigate, and come back to this after that...
Yeah, that's yarn. I recommend not to use yarn, it creates weird trees with needlessly duplicated dependencies, which breaks this library (and loads way more code than you want to load). Recent npm versions are much better at this.
@marijnh Thank you very much for your time and help. We finally diagnosed that our yarn.lock
file had two entries for prosemirror-state
one for version 1.3.3 and one for version 1.4.3. After deleting the yarn.lock
file and re-generating it with yarn, our errors went away. Sorry for the inconvenience.
We are having some trouble using ProseMirror in our TypeScript project - evolvedbinary/prosemirror-jdita.
Our CI (https://app.circleci.com/pipelines/github/evolvedbinary/prosemirror-jdita/238/workflows/2e59929e-174d-447f-b4a5-ee373ebd8fd0/jobs/916) shows these errors when compiling:
Our
package.json
imports the following dependencies:I feel like it is unlikely that this is expected behaviour with ProseMirror and TypeScript, and more likely that we are doing something silly (apologies if that is the case).
I did ask in your Forum (7 days ago), also I also asked in the TypeScript Discord channel (6 days ago) but got no response from either. Sorry to also ask here, but it does seem like a technical issue, and it is really blocking us from moving forward.
Kindest regards, and thank you. Adam.