Repository navigation
[lexical] Documentation: Add TSDoc for LexicalNodeReplacement and withKlass - #8471
Merged
etrepum merged 3 commits intoMay 7, 2026
Merged
Conversation
…hKlass Closes meta#6398. The concept page was added in meta#6890 but the API surface had no TSDoc, leaving readers who hit the runtime "withKlass will be required in a future version" warning without an in-source explanation. Adds TSDoc on the type and each of its three fields (replace, with, withKlass), explains why withKlass matters for node transforms and mutation listeners, and links to the existing concept page for the full example.
markselby9
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon,
takuyakanbr and
zurfyx
as code owners
May 7, 2026 02:25
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pre-emptive polish before maintainer review. Two correctness fixes and a trim: - 'with' now correctly says it's invoked by $applyNodeReplacement (which the $create* factories call) — not "whenever 'replace' is constructed", since direct `new` bypasses it. Adds the must-be-instance-of-withKlass invariant. - 'withKlass' splits transforms (fan out) from mutation listeners (redirect) — registerMutationListener resolves through the replacement chain rather than firing on both, so collapsing them was misleading. Also adds the prototype-extends-replace invariant and tightens the future-required wording. - Type-level paragraph drops the redundant CreateEditorArgs cross-link.
Pre-emptive style polish: drop internal-implementation references and multi-clause hedging in favor of declarative user-facing prose. - Drop the $applyNodeReplacement helper name from the 'with' doc - Drop the "Direct new bypasses" failure-mode footnote - Collapse the transform-vs-mutation-listener distinction into one user-facing clause (both register on the replacement) - Tighten the future-required wording to a single sentence - Drop "(asserted in dev)" implementation noise on the must-extend rule
etrepum
approved these changes
May 7, 2026
Merged
This branch was successfully deployed
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.
Summary
Addresses the API-documentation portion of #6398 — the concept page was added in #6890, but
LexicalNodeReplacementitself had no TSDoc, so readers who hit the runtime "withKlasswill be required in a future version" warning had nothing in-source to explain what to pass or why.This PR adds TSDoc on the type and each of its three fields:
replace— the core node class whose instances should be replaced.with— factory called wheneverreplaceis constructed; returns the substituted node.withKlass— explains why it matters:LexicalEditor.registerNodeTransformandLexicalEditor.registerMutationListenersubscriptions targeting the original class only continue to fire on the substituted instances ifwithKlassis provided. Notes the future-required status that the runtime warning at line 772 hints at.The type-level TSDoc links to the existing Node Replacement concept page rather than duplicating the full example here.
Scope
Pure docstring change — no logic, no behavior change, no test changes. Single file (
packages/lexical/src/LexicalEditor.ts), +26 / -0.The stackblitz-example sub-task that was discussed in the issue thread (and attempted in the now-closed #6930) is intentionally not in scope here; this PR addresses only the unchecked "API documentation is still missing" checkbox.
Closes #6398