Skip to content

Type mismatch between and addNodeView ResizableNodeView in v3.11.1 #7289

@kachkaev

Description

@kachkaev

Affected Packages

core

Version(s)

3.11.1

Bug Description

👋 folks! Just updated tiptip with all extensions from 3.11.0 to 3.11.1 and saw a blocking typescript error in CI. Here is a minimal reproduction:

import { ResizableNodeView } from "@tiptap/core";
import { Image } from "@tiptap/extension-image";

export const MyImage = Image.extend({
  addNodeView() { // ← 💥
    return ({ node, getPos }) => {
      return new ResizableNodeView({
        element: document.createElement("img"),
        node,
        getPos,
        onCommit: () => undefined,
        onUpdate: () => true,
      });
    };
  },
});
Type '(this: { name: string; options: ImageOptions; storage: any; editor: Editor; type: NodeType; 
parent: ((this: any) => NodeViewRenderer | null | undefined) | null | undefined; }) =>
({ node, getPos }: NodeViewRendererProps) => ResizableNodeView' is not assignable to type 
'(this: { name: string; options: ImageOptions; storage: any; editor: Editor; type: NodeType;
parent: any | null | undefined; }) => NodeViewRenderer | null | undefined'.

  Call signature return types '({ node, getPos }: NodeViewRendererProps) => ResizableNodeView'
  and 'NodeViewRenderer | null | undefined' are incompatible.

    Call signature return types 'ResizableNodeView' and 'NodeView' are incompatible.

      The types of 'contentDOM' are incompatible between these types.

        Type 'HTMLElement | undefined' is not assignable to type 'HTMLElement | null'.

          Type 'undefined' is not assignable to type 'HTMLElement | null'.ts(2322)

It does not need to be Image.extend. I tried Paragraph.extend and got the same result. The issue may be related to #6717, looking at the CHANGELOG.

Browser Used

Other

Code Example URL

No response

Expected Behavior

No TSC error for the above code, just as in 3.11.0

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Open SourceThe issue or pull reuqest is related to the open source packages of Tiptap.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions