Skip to content

[lexical-devtools-core] Bug Fix: Allow CustomPrintNodeFn to return undefined #7619

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

Merged
merged 1 commit into from
Jun 17, 2025

Conversation

achaljhawar
Copy link
Contributor

@achaljhawar achaljhawar commented Jun 12, 2025

Description

  • The current behavior is that the CustomPrintNodeFn type is strictly typed to return string. This causes a TypeScript error if your provided function returns undefined to fall back to the default node printing logic, even though the runtime code handles this scenario.
  • This PR modifies the CustomPrintNodeFn type definition to be string | undefined. This aligns the type with the existing runtime behavior and resolves the TypeScript error.

Closes #7612

Test plan

Before

If you provided a customPrintNode function like this, you would encounter a TypeScript error:

const myCustomPrintNode: CustomPrintNodeFn = (node) => {
  if (node.getType() === 'custom') {
    return 'Custom node representation';
  }
  return undefined; // TypeScript error: Type 'undefined' is not assignable to type 'string'.
};

After

With the updated type definition, the above code will no longer produce a TypeScript error. The type checking will succeed, reflecting the actual supported behavior of the generateContent function in lexical-devtools-core.

@facebook-github-bot
Copy link
Contributor

Hi @achaljhawar!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link

vercel bot commented Jun 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2025 1:01pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2025 1:01pm

@achaljhawar achaljhawar changed the title fix: allow CustomPrintNodeFn to return undefined [lexical-devtools-core] Bug Fix: Allow CustomPrintNodeFn to return undefined Jun 12, 2025
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 12, 2025
@lilshady lilshady added this pull request to the merge queue Jun 17, 2025
Merged via the queue into facebook:main with commit 5657ee1 Jun 17, 2025
39 checks passed
@etrepum etrepum mentioned this pull request Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: CustomPrintNodeFn should be able to return undefined
4 participants