[lexical-mark] Chore: Widen MarkNode method return types to boolean#8717
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
potatowagon
reviewed
Jun 18, 2026
potatowagon
left a comment
Contributor
There was a problem hiding this comment.
Reviewed by Navi (Tater Thoughts Bobblehead) on behalf of @potatowagon.
Assessment: LGTM ✅
This is a straightforward type-widening change in MarkNode — relaxing the return types of 4 override methods from literal types (false, true) to boolean.
What I checked:
- Correctness: The runtime behavior is unchanged — each method still returns the same literal value (
falseortrue). Only the TypeScript return-type annotation is widened. - Motivation: This aligns with Lexical's ongoing effort to deprecate unsafe narrow type parameters (see #8661). Widening to
booleanallows subclasses to override with different values without type errors — the narrow literals were unnecessarily restrictive for a method that semantically returns a boolean flag. - Backward compatibility: Widening a return type from a literal to its base type is a covariant change — existing callers expecting
boolean(the base class signature) are unaffected. Code that was relying on the literal type for type narrowing is extremely unlikely for these methods. - www compat: No removed exports, no renamed methods, no behavioral changes. Safe for Meta's internal consumers.
- Test coverage: No new tests needed — this is purely a type annotation change with no runtime effect. Core unit tests (22.x + 24.x), browser tests, and integrity checks all pass.
- Edge cases: None — literal narrowing removal has no runtime edge cases.
CI Status: Core tests all green (unit 22.x ✓, unit 24.x ✓, browser ✓, integrity ✓). CLA signed. Vercel deployed. E2e canary pending but irrelevant for a type-only change.
Ready to approve.
Co-authored-by: James Fitzsimmons <119275535+james-atticus@users.noreply.github.com>
etrepum
approved these changes
Jun 18, 2026
etrepum
approved these changes
Jun 18, 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
MarkNodeoverridescanInsertTextBefore,canInsertTextAfter, andcanBeEmptyfrom the baseElementNode, but narrowed their return types frombooleanto the literalfalse. This prevents anyone extendingMarkNodefrom overriding these methods to returntrue.For example, if you have a custom node (eg some CommentNode) that you want to allow the user to extend with
canInsertTextAfter, it will no longer satisfy the MarkNode types.This PR widens the three return types back to
booleanto matchElementNode, restoring type compatibility for subclasses.MarkNode's own behaviour is unchanged: each method still returnsfalse.Test plan
Before
A subclass overriding any of these methods to return
truefails to type-check:After
The same subclass type-checks successfully, and
MarkNode's default behaviour is unchanged (all three still returnfalse).