Skip to content
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

Recent port of ProseMirror to TypeScript and ProseMirror version bumps (hours ago) break TipTap #2836

Closed
1 of 2 tasks
tgv1975 opened this issue May 31, 2022 · 42 comments
Closed
1 of 2 tasks
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@tgv1975
Copy link

tgv1975 commented May 31, 2022

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:

image

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. 💖
@tgv1975 tgv1975 added the Type: Bug The issue or pullrequest is related to a bug label May 31, 2022
@tgv1975
Copy link
Author

tgv1975 commented May 31, 2022

I would add that if the above proves correct, existing TipTap consumers should refrain from installs and updates of their node_modules, since it will break their app.

@tgv1975 tgv1975 changed the title Recent migration of ProseMirror to TypesScript, and ProseMirror version bumps (hours ago) break TipTap Recent migration of ProseMirror to TypesScript and ProseMirror version bumps (hours ago) break TipTap May 31, 2022
@tgv1975 tgv1975 changed the title Recent migration of ProseMirror to TypesScript and ProseMirror version bumps (hours ago) break TipTap Recent migration of ProseMirror to TypeScript and ProseMirror version bumps (hours ago) break TipTap May 31, 2022
@tgv1975 tgv1975 changed the title Recent migration of ProseMirror to TypeScript and ProseMirror version bumps (hours ago) break TipTap Recent port of ProseMirror to TypeScript and ProseMirror version bumps (hours ago) break TipTap May 31, 2022
@NeoDobby
Copy link

NeoDobby commented May 31, 2022

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.

    "prosemirror-commands": "~1.2.2",
    "prosemirror-history": "~1.2.0",
    "prosemirror-keymap": "~1.1.5",
    "prosemirror-model": "~1.16.1",
    "prosemirror-schema-list": "~1.1.6",
    "prosemirror-state": "~1.3.4",
    "prosemirror-transform": "~1.4.2",
    "prosemirror-view": "~1.23.13",

(There may be other transitive dependencies to prosemirror in your project that you have to adjust)

@tgv1975
Copy link
Author

tgv1975 commented May 31, 2022

@NeoDobby Unfortunately that doesn't work, since the TipTap core package uses it's own package.json and node_modules, and these are dependencies, not peerDependencies. They don't even show up in the host app's package.json. Anything you change there will be overwritten when you do package updates, and not only for TipTap, even installing other, unrelated packages. Also, as you said, there may be other dependencies all over the repo.

Have you managed to employ this solution, or is it theoretical?

I don't really see a self-serve solution to this, unless you fork TipTap and change to fixed versions there, then use the fork in your host app.

That's why I think this is pretty bad, there isn't really any workaround a consumer of the library can use. A fresh install of TipTap now uses an incompatible dependency, plain and simple, as far as I can tell, and that's not really solvable in a host project. There's not even the option to use an older version of TipTap, since the way ProseMirror versions are requested in package.json (not fixed) goes way, way back.

I am of course open to any solutions in the meanwhile.

@NeoDobby
Copy link

NeoDobby commented May 31, 2022

@tgv1975 Yes, I tested this before posting. As long as your restricted prosemirror dependencies (in the host app's package.json) fall into the wider version ranges used by tiptap, npm should only install each prosemirror dependency once (in the main node_modules folder). If the version ranges didn't match, then each tiptap dependency would get its own prosemirror versions 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.

@tgv1975
Copy link
Author

tgv1975 commented May 31, 2022

@NeoDobby I only now realize the nuance in your solution. That's clever. Will certainly try it. Thanks!

@tgv1975
Copy link
Author

tgv1975 commented May 31, 2022

@NeoDobby Unfortunately this trick doesn't seem to work on

Node 16.15.0
npm 7.18.1
yarn 1.22.15

For example, the prosemirror-view I get is still 1.24.1 (confirmed with yarn info prosemirror-view version).

In my app's package.json:

image

Actual installed version:

image

Is it possible that in your case there was some cache involved?

PS: of course, there may be a difference between yarn and npm at play here as well. Bottom line is that, at least with yarn, this doesn't seem to work.

@NeoDobby
Copy link

@tgv1975 you put @types/prosemirror-view instead of prosemirror-view in your package.json. Remove the @types/ scope and it should work.

@tgv1975
Copy link
Author

tgv1975 commented May 31, 2022

Apologies, wrong screenshot. This is the actual lib in my package.json:

image

It was there before, I just took the screenshot wrong.

PS: I had copied all the dependencies verbatim from the TipTap core package.json into the app's, that's why the @types are also in there. Unfortunately, it's not a simple misunderstanding.

@tgv1975
Copy link
Author

tgv1975 commented Jun 1, 2022

Having investigating this further, there is a way to mitigate it until a permanent solution emerges, when using yarn.

WORKAROUND:

Add the following resolutions entry to your application's package.json, at root level (same level as your dependencies):

"resolutions": {
        "prosemirror-commands": "~1.2.1",
        "prosemirror-keymap": "~1.1.5",
        "prosemirror-model": "~1.16.1",
        "prosemirror-schema-list": "~1.1.6",
        "prosemirror-state": "~1.3.4",
        "prosemirror-transform": "~1.3.3",
        "prosemirror-view": "~1.23.6",
        "@types/prosemirror-commands": "~1.0.4",
        "@types/prosemirror-keymap": "~1.0.4",
        "@types/prosemirror-model": "~1.16.0",
        "@types/prosemirror-schema-list": "~1.0.3",
        "@types/prosemirror-state": "~1.2.8",
        "@types/prosemirror-transform": "~1.1.5",
        "@types/prosemirror-view": "~1.23.1"
  }

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 @types are also added here, as otherwise the newer versions would cause critical typing errors.

The equivalent for npm 8+ would be the overrides entry in package.json, but according to @NeoDobby, with npm it may work by simply putting these under your dependencies.

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.

@bdbch
Copy link
Member

bdbch commented Jun 6, 2022

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.

@rajwitt
Copy link

rajwitt commented Jun 6, 2022

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!!!

	"overrides": {
		"prosemirror-collab": "1.2.2",
		"prosemirror-commands": "1.1.4",
		"prosemirror-dropcursor": "1.3.2",
		"prosemirror-gapcursor": "1.1.5",
		"prosemirror-history": "1.1.3",
		"prosemirror-inputrules": "1.1.3",
		"prosemirror-keymap": "1.1.4",
		"prosemirror-model": "1.13.1",
		"prosemirror-schema-list": "1.1.4",
		"prosemirror-state": "1.3.3",
		"prosemirror-tables": "1.1.1",
		"prosemirror-transform": "1.2.8",
		"prosemirror-utils": "0.9.6",
		"prosemirror-view": "1.16.5"
	}

the above override idea may also have been a great solution for this one: #577

@Lwrless
Copy link

Lwrless commented Jun 22, 2022

Still experiencing this issue with latest tiptap packages on npm.

And I can confirm that overriding prosemirror packages works for now.

@bdbch
Copy link
Member

bdbch commented Jun 22, 2022

@Lwrless you mean the typing issues described in the original issue screenshots?

@Lwrless
Copy link

Lwrless commented Jun 22, 2022

@Lwrless you mean the typing issues described in the original issue screenshots?

Yes, it was Generic type 'Plugin<PluginState>' requires between 0 and 1 type arguments., from bubble menu extension.

@rfgamaral
Copy link
Contributor

We haven't been able to update to the latest Tiptap versions either, but I'm still a bit unsure where the problem lies.

We are not building our editor directly in the final apps, it's a custom package that it's then used in the final app. The custom package builds the distribution code with TypeScript (no babel or anything similar), and then is published to GitHub's Package Registry. The final app uses Webpack, and when I attempt to use a version of our package that includes the latest Tiptap versions, our web app breaks when opening a route that contains the editor component.

I'm thinking it could be related to the ProseMirror package changes, and not exactly Tiptap's, but I have yet to dig deeper into this.

@bdbch
Copy link
Member

bdbch commented Jun 22, 2022

@rfgamaral can you post your error message so I can try to reproduce those issues?

@rfgamaral
Copy link
Contributor

@rfgamaral can you post your error message so I can try to reproduce those issues?

At first, I got this, which doesn't tell us much:

image

image

But that's because we have an error boundary for the whole app. After removing the error boundary, I got this:

image

@bdbch
Copy link
Member

bdbch commented Jun 23, 2022

Mh thats weird. Could you check if you load a different prosemirror-state version somewhere in your project? This error usually occurs for me when different versions of prosemirror-state are loaded that cause index instanced plugins to be instanced again at plugin$ / plugin$1, etc.

Tiptap itself now comes with 1.4.0 included.

@bdbch
Copy link
Member

bdbch commented Jun 23, 2022

You can also hit me up on Discord if you want faster communication for those issues so we can get them resolved ASAP.

@benkroeger
Copy link
Contributor

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

@rfgamaral
Copy link
Contributor

@benkroeger I'm having that exact issue with prosemirror-codemark, is there a workaround?

@rfgamaral
Copy link
Contributor

@bdbch My problem above is caused by prosemirror-codemark, didn't notice I was in the actual issue where I posted that problem 😅

@bdbch
Copy link
Member

bdbch commented Jun 23, 2022

Ah I see - so your issue is more related to codemark then. If I can help somehow to resolve this issue let me know.

@benkroeger
Copy link
Contributor

@rfgamaral no workaround that I know of.

@bdbch I think the problem @rfgamaral described is not related to the this issue.

@rfgamaral
Copy link
Contributor

I believe I worked around this issue on our side by adding this to our Webpack configuration:

resolve: {
    alias: {
        'prosemirror-state': path.resolve('./node_modules/prosemirror-state'),
    }
}

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.

@cklogs
Copy link

cklogs commented Jun 24, 2022

The suggested fix above, of overriding the listed prosemirror packages, is not working for me.
I am on typescript v4.6.3.

Is there a rough ETA on when this issue might be resolved?

@bdbch
Copy link
Member

bdbch commented Jun 25, 2022

The suggested fix above, of overriding the listed prosemirror packages, is not working for me.
I am on typescript v4.6.3.

Is there a rough ETA on when this issue might be resolved?

Are you having the same issue as @rfgamaral ?

@christian-kolb
Copy link

christian-kolb commented Jun 25, 2022

I can't seem to find a set of packages that works without build issues. I use NPM 6 and have the tiptap-* and the prosemirror-* packages in my dependencies. The prosemirror packages are installed with the fixed version.

For example this set doesn't work:

"@tiptap/core": "^2.0.0-beta.176",
"@tiptap/extension-bold": "^2.0.0-beta.25",
"@tiptap/extension-bullet-list": "^2.0.0-beta.26",
"@tiptap/extension-document": "^2.0.0-beta.15",
"@tiptap/extension-link": "^2.0.0-beta.33",
"@tiptap/extension-list-item": "^2.0.0-beta.20",
"@tiptap/extension-ordered-list": "^2.0.0-beta.27",
"@tiptap/extension-paragraph": "^2.0.0-beta.23",
"@tiptap/extension-text": "^2.0.0-beta.15",
"@tiptap/vue-2": "^2.0.0-beta.79",
"prosemirror-collab": "1.2.2",
"prosemirror-commands": "1.1.4",
"prosemirror-dropcursor": "1.3.2",
"prosemirror-gapcursor": "1.1.5",
"prosemirror-history": "1.1.3",
"prosemirror-inputrules": "1.1.3",
"prosemirror-keymap": "1.1.4",
"prosemirror-model": "1.13.1",
"prosemirror-schema-list": "1.1.4",
"prosemirror-state": "1.3.3",
"prosemirror-tables": "1.1.1",
"prosemirror-transform": "1.2.8",
"prosemirror-utils": "0.9.6",
"prosemirror-view": "1.16.5",

Can anyone post a set of versions that works for you?

@dougalg
Copy link

dougalg commented Jun 26, 2022

Is this something that could be resolved with fixed-version peerDependencies in TipTap?

@bdbch
Copy link
Member

bdbch commented Jun 26, 2022

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?

@dougalg
Copy link

dougalg commented Jun 26, 2022

Personally, I just ran into this with the extensions that are using prosemirror-state's Plugin interface:

ERROR in ROOT_DIR/node_modules/@tiptap/extension-bubble-menu/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts(43,76):
43:76 Generic type 'Plugin<PluginState>' requires between 0 and 1 type arguments.
    41 |     destroy(): void;
    42 | }
  > 43 | export declare const BubbleMenuPlugin: (options: BubbleMenuPluginProps) => Plugin<any, any>;
       |                                                                            ^
    44 | 
ERROR in ROOT_DIR/node_modules/@tiptap/extension-floating-menu/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts(40,80):
40:80 Generic type 'Plugin<PluginState>' requires between 0 and 1 type arguments.
    38 |     destroy(): void;
    39 | }
  > 40 | export declare const FloatingMenuPlugin: (options: FloatingMenuPluginProps) => Plugin<any, any>;
       |                                                                                ^
    41 | 
Version: typescript 4.4.3

Latest Tiptap versions:

		"@tiptap/core": "2.0.0-beta.180",
		"@tiptap/extension-bold": "2.0.0-beta.28",
		"@tiptap/extension-bullet-list": "2.0.0-beta.29",
		"@tiptap/extension-italic": "2.0.0-beta.28",
		"@tiptap/extension-link": "2.0.0-beta.42",
		"@tiptap/extension-list-item": "2.0.0-beta.23",
		"@tiptap/extension-mention": "2.0.0-beta.101",
		"@tiptap/extension-ordered-list": "2.0.0-beta.30",
		"@tiptap/extension-paragraph": "2.0.0-beta.26",
		"@tiptap/extension-text-align": "2.0.0-beta.31",
		"@tiptap/extension-underline": "2.0.0-beta.25",
		"@tiptap/starter-kit": "2.0.0-beta.189",
		"@tiptap/vue-2": "2.0.0-beta.83",

Note that I do not explicitly import Prosemirror anywhere in my project, but I current have the most recent prosemirror-state:

prosemirror-state@1.4.1

@christian-kolb
Copy link

@bdbch I've tried multiple combinations, but to be sure and able to reproduce it, I tried them now again and here are the variants. Before the each test, I nuked the npm cache with npm cache clear --force.

Tests

Latest without locked prosemirror versions

No tiptap packages in the package.json, then copied them in at once and run npm install.

"@tiptap/core": "^2.0.0-beta.180",
"@tiptap/extension-bold": "^2.0.0-beta.28",
"@tiptap/extension-bullet-list": "^2.0.0-beta.29",
"@tiptap/extension-document": "^2.0.0-beta.17",
"@tiptap/extension-link": "^2.0.0-beta.42",
"@tiptap/extension-list-item": "^2.0.0-beta.23",
"@tiptap/extension-ordered-list": "^2.0.0-beta.30",
"@tiptap/extension-paragraph": "^2.0.0-beta.26",
"@tiptap/extension-text": "^2.0.0-beta.17",
"@tiptap/vue-2": "^2.0.0-beta.83",

With it, I get exactly the same result as @dougalg:

ERROR in /var/www/html/node_modules/@tiptap/extension-bubble-menu/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts(43,76):
2022-06-26T07:42:36.869373793Z 43:76 Generic type 'Plugin<PluginState>' requires between 0 and 1 type arguments.
2022-06-26T07:42:36.869378668Z     41 |     destroy(): void;
2022-06-26T07:42:36.869381127Z     42 | }
2022-06-26T07:42:36.869383335Z   > 43 | export declare const BubbleMenuPlugin: (options: BubbleMenuPluginProps) => Plugin<any, any>;
2022-06-26T07:42:36.869385877Z        |                                                                            ^
2022-06-26T07:42:36.869388043Z     44 | 
2022-06-26T07:42:36.869489002Z Version: typescript 4.3.4
2022-06-26T07:42:36.869499877Z Time: 8046ms
2022-06-26T07:42:36.869501877Z ERROR in /var/www/html/node_modules/@tiptap/extension-floating-menu/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts(40,80):
2022-06-26T07:42:36.869522585Z 40:80 Generic type 'Plugin<PluginState>' requires between 0 and 1 type arguments.
2022-06-26T07:42:36.869526168Z     38 |     destroy(): void;
2022-06-26T07:42:36.869528752Z     39 | }
2022-06-26T07:42:36.869532085Z   > 40 | export declare const FloatingMenuPlugin: (options: FloatingMenuPluginProps) => Plugin<any, any>;
2022-06-26T07:42:36.869535168Z        |       

Latest version with locked prosemirror versions

Same set of tiptap packages but with locked versions of prosemirror like @rajwitt suggested:

"@tiptap/core": "^2.0.0-beta.180",
"@tiptap/extension-bold": "^2.0.0-beta.28",
"@tiptap/extension-bullet-list": "^2.0.0-beta.29",
"@tiptap/extension-document": "^2.0.0-beta.17",
"@tiptap/extension-link": "^2.0.0-beta.42",
"@tiptap/extension-list-item": "^2.0.0-beta.23",
"@tiptap/extension-ordered-list": "^2.0.0-beta.30",
"@tiptap/extension-paragraph": "^2.0.0-beta.26",
"@tiptap/extension-text": "^2.0.0-beta.17",
"@tiptap/vue-2": "^2.0.0-beta.83",
"prosemirror-collab": "1.2.2",
"prosemirror-commands": "1.1.4",
"prosemirror-dropcursor": "1.3.2",
"prosemirror-gapcursor": "1.1.5",
"prosemirror-history": "1.1.3",
"prosemirror-inputrules": "1.1.3",
"prosemirror-keymap": "1.1.4",
"prosemirror-model": "1.13.1",
"prosemirror-schema-list": "1.1.4",
"prosemirror-state": "1.3.3",
"prosemirror-tables": "1.1.1",
"prosemirror-transform": "1.2.8",
"prosemirror-utils": "0.9.6",
"prosemirror-view": "1.16.5",

With it I get the same result:

ERROR in /var/www/html/node_modules/@tiptap/extension-bubble-menu/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts(43,76):
2022-06-26T08:02:56.385181678Z 43:76 Generic type 'Plugin<PluginState>' requires between 0 and 1 type arguments.
2022-06-26T08:02:56.385186261Z     41 |     destroy(): void;
2022-06-26T08:02:56.385188636Z     42 | }
2022-06-26T08:02:56.385190969Z   > 43 | export declare const BubbleMenuPlugin: (options: BubbleMenuPluginProps) => Plugin<any, any>;
2022-06-26T08:02:56.385193469Z        |                                                                            ^
2022-06-26T08:02:56.385195678Z     44 | 
2022-06-26T08:02:56.385306178Z Version: typescript 4.3.4
2022-06-26T08:02:56.385314678Z ERROR in /var/www/html/node_modules/@tiptap/extension-floating-menu/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts(40,80):
2022-06-26T08:02:56.385338969Z 40:80 Generic type 'Plugin<PluginState>' requires between 0 and 1 type arguments.
2022-06-26T08:02:56.385342178Z     38 |     destroy(): void;
2022-06-26T08:02:56.385345386Z     39 | }
2022-06-26T08:02:56.385348136Z   > 40 | export declare const FloatingMenuPlugin: (options: FloatingMenuPluginProps) => Plugin<any, any>;
2022-06-26T08:02:56.385351261Z        |                                                                                ^
2022-06-26T08:02:56.385354136Z     41 | 

Deep dive

When looking into the bubble-menu-plugin.d.ts, we see that the following is marked as an issue:

export declare const BubbleMenuPlugin: (options: BubbleMenuPluginProps) => Plugin<any, any>;

Same goes with the floating menu:

export declare const FloatingMenuPlugin: (options: FloatingMenuPluginProps) => Plugin<any, any>;

When looking into the Plugin of prosemirror-state (prosemirror-state/dist/index.d.ts), it's defined as:

declare class Plugin<PluginState = any> {

Manually overwriting them locally (just for debugging purposes) to the following, solves the problem:

export declare const BubbleMenuPlugin: (options: BubbleMenuPluginProps) => Plugin<any>;

But this of course is no solution. I don't know where those types are generated, because they are not part of the tiptap/packages/extension-bubble-menu here in the repository.

When looking into the history of the plugin.ts of prosemirror-state, I can't find a variant where it was every defined with two parameters.

So to me it looks like the generation of the dist files has broken somehow and generates this invalid types. The bubble-menu-plugin.ts in the node_modules/@tiptap/extension-bubble-menu/src doesn't seem to have 2 parameters, but just one. Therefore using the component works. It's "just" the build that fails due to the types not matching.

@benkroeger
Copy link
Contributor

benkroeger commented Jun 27, 2022

types for prosemirror-* packages have previously been separted and only incorporated with the latest significant updates.

generation of the dist files has broken

@christian-kolb this appears unlikely to me.

@christian-kolb
Copy link

christian-kolb commented Jun 27, 2022

@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-menu and extension-floating-menu packages.

@christian-kolb
Copy link

@benkroeger @dougalg The release was just triggered and I can now build everything successfully 🙂
Looks to me as if this issue might be closed.

@bdbch
Copy link
Member

bdbch commented Jun 27, 2022

That's great! I'm going to close the issue for now. Feel free to reopen if it's still an issue.

@bdbch bdbch closed this as completed Jun 27, 2022
@dougalg
Copy link

dougalg commented Jun 27, 2022

@christian-kolb @bdbch I can confirm that my build now runs without errors with latest packages, thank you!

@benkroeger
Copy link
Contributor

benkroeger commented Jun 27, 2022

there are still issues for me. the extension-blockquote imports @tiptap/core@2.0.0-beta.174 which indirectly imports @types/prosemirror-model@1.16.1 and @types/prosemirror-transform@1.1.6 instead of using the types from the lates prosemirror-model and prosemirror-state packages.

Also, @tiptap/core@2.0.0-beta.174 seems to have more type issues internally:

image

@bdbch or @tgv1975 can you please re-open the issue?

@bdbch bdbch reopened this Jun 27, 2022
@benkroeger
Copy link
Contributor

image

node --version: v16.15.1
npm --version: 8.11.0

@benkroeger
Copy link
Contributor

benkroeger commented Jun 27, 2022

well, apparently - since I don't have @tiptap/core listed as a dependency explicitly - npm chose to install the cached one... beta.174 while there was already beta.181 out there. beta.181 does fix the issues. I'm very sorry for the confusion.
Issue is solved for me as well.

@bdbch issue can be closed again :)

@bdbch
Copy link
Member

bdbch commented Jun 27, 2022

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!

@dominiczy
Copy link

dominiczy commented Jan 6, 2023

This issue is still happening for me with extension-bubble-menu@^2.0.0-beta.209 and "@tiptap/core" "^2.0.0-beta.209". The line @christian-kolb mentioned looks correct in my node_modules. However it's definitely still an issue in BubbleMenu (if I remove the component from my code it doesn't happen)

Edit: This was just me mixing up the import BubbleMenu from '@tiptap/extension-bubble-menu' and import { BubbleMenu, } from '@tiptap/react' imports. The tiptap docs are not very clear on that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests