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

Version incompatibility in @prosemirror-adapter/svelte vs SvelteKit #28

Open
radio-miskovice opened this issue Apr 23, 2023 · 5 comments

Comments

@radio-miskovice
Copy link

When using the code in examples/svelte I get error in this code (Editor.svelte, lines 32, 27, etc.):

 // line 29:
  function editor(element: HTMLElement) {
    editorView = createEditorView(element, {
      paragraph: nodeViewFactory({
        component: Paragraph,
        as: 'div',
        contentAs: 'p'
      }),
      heading: nodeViewFactory({
        component: Heading
      })
    }, [
      new Plugin({
        view: pluginViewFactory({
          component: Size
        })
      }),
...

The error reads:

Type 'typeof Paragraph__SvelteComponent_' is not assignable to type 'SvelteNodeViewComponent'.
Types of parameters 'options' and 'options' are incompatible.
Type 'ComponentConstructorOptions' is not assignable to type 'ComponentConstructorOptions<Record<string, never>>'.
Type 'EmptyProps' is not assignable to type 'Record<string, never>'.
Index signature for type 'string' is missing in type 'EmptyProps'.ts(2322)

Not sure how exactly approach a fix... My guess is that changing type in the adapter code should suffice, but did not have the courage to look inside, yet.

"@sveltejs/kit": "^1.5.0",
"@sveltejs/adapter-auto": "^2.0.0",
"svelte": "^3.54.0",
"svelte-check": "^3.0.1",
"@prosemirror-adapter/svelte": "^0.2.4",

@Saul-Mirone
Copy link
Collaborator

Does it help if you update svelte to 3.57.0?

@radio-miskovice
Copy link
Author

Unfortunately it doesn't.

export const createEditorView = (element: HTMLElement, nodeViews: Record<string, NodeViewConstructor>, plugins: Plugin[]) => {
...

It seems that nodeViews' type should be different, but so far I have little idea 1. what exactly should be the change, 2. if there are any potential adverse effects of such a change.

@Saul-Mirone
Copy link
Collaborator

Can you provide a stackblitz or codesandbox link? I still cannot reproduce.

@radio-miskovice
Copy link
Author

I will check what is definition of ComponentConstructorOptions. If it is based on Record<> then it could be some option in typescript config. Stackblitz or Codesandbox later.

@Rimantovas
Copy link

Have you managed to solve it? @radio-miskovice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants