tiptap: Recent port of ProseMirror to TypeScript and ProseMirror version bumps (hours ago) break TipTap
What’s the bug you are facing?
ProseMirror has been recently ported to TypeScript, and a few hours ago ProseMirror lib versions have been bumped.
Due to TipTap not using fixed dependency versions (for example, in core), when doing a clean install of TipTap now, the new ProseMirror libs are used, and they are incompatible with TipTap on the TypeScript side.
For example, when compiling something that uses TipTap, I now get typing errors like:
ERROR: node_modules/@tiptap/core/dist/packages/core/src/Editor.d.ts:95:39 - error TS2315: Type 'Transaction' is not generic.
95 captureTransaction(fn: Function): Transaction<any> | null;
node_modules/@tiptap/core/dist/packages/core/src/NodeView.d.ts:18:9 - error TS2416: Property 'contentDOM' in type 'NodeView<Component, Editor, Options>' is not assignable to the same property in base type 'NodeView'.
Type 'Element' is missing the following properties from type 'HTMLElement': accessKey, accessKeyLabel, autocapitalize, dir, and 111 more.
18 get contentDOM(): Element | null;
node_modules/@tiptap/core/dist/packages/core/src/helpers/findParentNode.d.ts:8:11 - error TS2315: Type 'Node' is not generic.
8 node: import("prosemirror-model").Node<any>;
node_modules/@tiptap/extension-bubble-menu/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts:43:76 - error TS2707: Generic type 'Plugin<PluginState>' requires between 0 and 1 type arguments.
43 export declare const BubbleMenuPlugin: (options: BubbleMenuPluginProps) => Plugin<any, any>;
node_modules/@tiptap/extension-table/dist/packages/extension-table/src/utilities/createTable.d.ts:2:129 - error TS2315: Type 'Fragment' is not generic.
2 export declare function createTable(schema: Schema, rowsCount: number, colsCount: number, withHeaderRow: boolean, cellContent?: Fragment<Schema> | ProsemirrorNode<Schema> | Array<ProsemirrorNode<Schema>>): ProsemirrorNode;
node_modules/@tiptap/extension-table/dist/packages/extension-table/src/utilities/createTable.d.ts:2:148 - error TS2315: Type 'Node' is not generic.
2 export declare function createTable(schema: Schema, rowsCount: number, colsCount: number, withHeaderRow: boolean, cellContent?: Fragment<Schema> | ProsemirrorNode<Schema> | Array<ProsemirrorNode<Schema>>): ProsemirrorNode;
node_modules/@tiptap/extension-table/dist/packages/extension-table/src/utilities/createTable.d.ts:2:180 - error TS2315: Type 'Node' is not generic.
2 export declare function createTable(schema: Schema, rowsCount: number, colsCount: number, withHeaderRow: boolean, cellContent?: Fragment<Schema> | ProsemirrorNode<Schema> | Array<ProsemirrorNode<Schema>>): ProsemirrorNode;
Here’s a screenshot which is perhaps more readable than the above dump:

This makes a fresh TipTap install completely unusable, for both new users, and existing users who refresh their node_modules.
Which browser was this experienced in? Are any special extensions installed?
Not a browser issue, this pertains to the installation/transpilation phase.
How can we reproduce the bug on our side?
Do a fresh install of TipTap. I’m using these:
"@tiptap/core": "2.0.0-beta.176",
"@tiptap/extension-blockquote": "2.0.0-beta.26",
"@tiptap/extension-bubble-menu": "2.0.0-beta.56",
"@tiptap/extension-bullet-list": "2.0.0-beta.26",
"@tiptap/extension-color": "2.0.0-beta.9",
"@tiptap/extension-gapcursor": "2.0.0-beta.34",
"@tiptap/extension-hard-break": "2.0.0-beta.30",
"@tiptap/extension-highlight": "2.0.0-beta.33",
"@tiptap/extension-horizontal-rule": "2.0.0-beta.31",
"@tiptap/extension-image": "2.0.0-beta.27",
"@tiptap/extension-link": "2.0.0-beta.38",
"@tiptap/extension-list-item": "2.0.0-beta.20",
"@tiptap/extension-ordered-list": "2.0.0-beta.27",
"@tiptap/extension-placeholder": "2.0.0-beta.48",
"@tiptap/extension-subscript": "2.0.0-beta.10",
"@tiptap/extension-superscript": "2.0.0-beta.10",
"@tiptap/extension-table": "2.0.0-beta.49",
"@tiptap/extension-table-cell": "2.0.0-beta.20",
"@tiptap/extension-table-header": "2.0.0-beta.22",
"@tiptap/extension-table-row": "2.0.0-beta.19",
"@tiptap/extension-text-align": "2.0.0-beta.29",
"@tiptap/extension-text-style": "2.0.0-beta.23",
"@tiptap/extension-underline": "2.0.0-beta.23",
"@tiptap/starter-kit": "2.0.0-beta.185",
Then, instantiate an editor, and transpile that code.
Can you provide a CodeSandbox?
N/A
What did you expect to happen?
A normal transpilation of the code using TipTap.
Anything to add? (optional)
I believe the quick solution to this is to set all ProseMirror dependencies to the last working fixed versions, thus reverting to normal, until there is time for TipTap to catch up with the ProseMirror TypeScript port. The latter will likely take a long time, during which TipTap installs are essentially unusable.
Did you update your dependencies?
- Yes, I’ve updated my dependencies to use the latest version of all packages.
Are you sponsoring us?
- Yes, I’m a sponsor. 💖
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 42 (21 by maintainers)
A quick workaround for those facing the same issue is restricting the prosemirror dependencies to the previous minor version in your own package.json, e.g.
(There may be other transitive dependencies to prosemirror in your project that you have to adjust)
I believe I worked around this issue on our side by adding this to our Webpack configuration:
Although probably unrelated to the issue at hand, since I’ve discussed this here, I thought it was best to share the workaround here too.
Having investigating this further, there is a way to mitigate it until a permanent solution emerges, when using
yarn.WORKAROUND:
Add the following
resolutionsentry to your application’spackage.json, at root level (same level as yourdependencies):These dependencies are copied verbatim from the TipTap core
package.json, and altered to prevent installing higher versions, except patches (^changed to~) as per @NeoDobby’s suggestion - thanks for that! The@typesare also added here, as otherwise the newer versions would cause critical typing errors.The equivalent for
npm 8+would be theoverridesentry inpackage.json, but according to @NeoDobby, withnpmit may work by simply putting these under yourdependencies.This should only be a temporary workaround until the root cause is properly addressed in TipTap core.
The good news about this workaround actually resolving the problem is that the actual definitive solution is really simple: just make core dependencies fixed version and republish TipTap. I think having fixed dependency versions is good practice anyway, gives the publisher full control over them.
Even allowing patches can turn sour, as there is a gap between the publisher testing the package and users installing it on their machine, and if an incompatible patch in the dependency has been published in the meanwhile, there will be bugs and bug reports that could have been avoided.
@tgv1975 Yes, I tested this before posting. As long as your restricted
prosemirrordependencies (in the host app’spackage.json) fall into the wider version ranges used bytiptap, npm should only install eachprosemirrordependency once (in the mainnode_modulesfolder). If the version ranges didn’t match, then eachtiptapdependency would get its ownprosemirrorversions in e.g.node_modules/@tiptap/core/node_modules, and the workaround wouldn’t work.Note: I tested this with npm 6 and 7, not sure if it also works with 8.
But I agree, this is only a workaround until the issue is fixed properly.
@benkroeger I discussed and validated it with @bdbch on the weekend via Discord. The types are correct, but something went wrong in the release which lead to the wrong types being included. They will solve it with a new release for the relevant packages 🙂
EDIT: The problems are in the
extension-bubble-menuandextension-floating-menupackages.I’ve seen a similar error with prosemirror-codemark - which is related to a mix of ESM and UMD builds. TLDR: When a dependency is UMD build and your project uses ESM builds, prosemirror-state is loaded twice (at lease during development e.g. with vite) - once from prosemirror-state’s esm path and once from prosemirror-state’s umd path
BOSS @NeoDobby @tgv1975 - this was impacting v1 also! - thanks for sharing the above!!! 👍🏻
but your above notes allowed me to trace the different package dependencies
Sub Modules
to then dedupe and create a what appears to be working overwrite in the package.json!!!
the above override idea may also have been a great solution for this one: https://github.com/ueberdosis/tiptap/issues/577
Thanks for this issue! We’ll make sure to work on a port to the new Typescript version ASAP so we don’t need workarounds here. I’ll discuss this in the team and reproritize issues.
Thanks @benkroeger for letting me know. I think we still should improve the dependency management and versioning for tiptap to make it easier to find potential incompatibilities faster!
well, apparently - since I don’t have
@tiptap/corelisted as a dependency explicitly - npm chose to install the cached one…beta.174while there was alreadybeta.181out there.beta.181does fix the issues. I’m very sorry for the confusion. Issue is solved for me as well.@bdbch issue can be closed again 😃
@christian-kolb @bdbch I can confirm that my build now runs without errors with latest packages, thank you!
Personally, I just ran into this with the extensions that are using
prosemirror-state’sPlugininterface:Latest Tiptap versions:
Note that I do not explicitly import Prosemirror anywhere in my project, but I current have the most recent prosemirror-state:
I think so! We could do some evaluations and testing on how to make this whole dependency list easier to match up. We also thought about a different versioning model (for example having all tiptap-packages matched to one version instead of independent versions) but we won’t change this until we’re hitting 2.0.0.
Right now I’d suggest to use the latest prosemirror and tiptap packages @christian-kolb - I guess you tried that already, what issues did you run into?