[Bug]: In addOptions
. the type of this.parent
is wrong.
#5768
Labels
Category: Open Source
The issue or pull reuqest is related to the open source packages of Tiptap.
Type: Bug
The issue or pullrequest is related to a bug
Affected Packages
core
Version(s)
2.9.1
Bug Description
When extending a node & implementing
addOptions
, the type ofthis.parent
is incorrect.For a
Node<T>
,this.parent
is typed as() => T
, denoting that it is safe to call directly likethis.parent()
. However,this.parent
might beundefined
, as is documented, so we must callthis.parent?.()
.Because of the inaccurate type, it is easy to forget to add the
?.
optional chaining. Furthermore, linting rules such asno-unnecessary-condition
can automatically strip the?.
out, which can cause type errors be thrown at runtime.Browser Used
Chrome
Code Example URL
No response
Expected Behavior
In the
addOptions
method,this.parent
should have a type of(() => T) | undefined
to match the implementation & documentation.Additional Context (Optional)
No response
Dependency Updates
The text was updated successfully, but these errors were encountered: