[lexical-extension] Fix: Remove JSX dependency from DecoratorTextNode#8328
Merged
etrepum merged 1 commit intofacebook:mainfrom Apr 10, 2026
Merged
Conversation
Change DecoratorTextNode to extend DecoratorNode<unknown> instead of DecoratorNode<JSX.Element>, removing the dependency on React's JSX types from @lexical/extension which has no React dependency declared. Fixes facebook#8325
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zurfyx
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
DecoratorTextNodepreviously extendedDecoratorNode<JSX.Element>, which pulled in a type-onlyimport type {JSX} from 'react'in@lexical/extension.@lexical/extensiondoes not declare a dependency on React, so this coupled a framework-agnostic package to React's JSX types for no runtime reason.This PR changes
DecoratorTextNodeto extendDecoratorNode<unknown>and removes theJSXimport. Subclasses (e.g.EntityNode,DateTimeNode) can still returnJSX.Elementfrom their owndecorate()overrides because any value is assignable tonull | unknown. The corresponding.flowdeclaration is updated to match (DecoratorTextNode extends DecoratorNode<mixed>, no longer generic).DecoratorTextNodecould be generic itself, but there's basically no value to having anyDecoratorNodeuse a generic since$isDecoratorNodeis unsound and effectively just casts to whatever since there's no runtime reflection of this generic that it could use to verify the intended host environment. We should really just deprecate all DecoratorNode generics.Closes #8325
Test plan
Existing tests and type check should still work (including react decorator subclasses of DecoratorTextNode).