You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature: CustomPrintNodeFn should be able to return undefined #7612
Use a TreeView from @lexical/react/LexicalTreeView an supply a custom customPrintNode function.
(Implicitly) return undefined to get the default behaviour for nodes whose representation you don't want to override.
Type error due to CustomPrintNodeFn return type being string.
The current behavior
TypeScript type-checking fails:
error TS2322: Type '(node: LexicalNode) => string | undefined' is not assignable to type 'CustomPrintNodeFn'.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
The expected behavior
Type checking succeeds.
More info
The code allows returning undefined from customPrintNode to get the default behaviour:
Seems like you've already sorted out what the fix could be, go ahead and submit a PR. Alternatively, your code can return an empty string instead of undefined which will have the same behavior as what you expect undefined to do.
Activity
etrepum commentedon Jun 8, 2025
Seems like you've already sorted out what the fix could be, go ahead and submit a PR. Alternatively, your code can return an empty string instead of undefined which will have the same behavior as what you expect undefined to do.
[-]Bug:[/-][+]Feature: CustomPrintNodeFn should be able to return undefined[/+]achaljhawar commentedon Jun 10, 2025
can I work on this issue?
etrepum commentedon Jun 10, 2025
Yes, anyone may submit a PR for any issue.