Repository navigation
[lexical] Bug Fix: Keep the deprecated unchecked node type arguments in the Flow declarations - #9529
Merged
Merged
Conversation
…in the Flow declarations ## Description v0.53.0 (#9479) removed the unchecked type-argument overloads of `getParent`, `getParentOrThrow`, `getParents`, `getPreviousSibling`, `getPreviousSiblings`, `getNextSibling`, `getNextSiblings`, `getChildren`, `getFirstChild`, `getFirstChildOrThrow`, `getLastChild`, `getLastChildOrThrow`, `getChildAtIndex`, `getFirstDescendant`, `getLastDescendant`, `getDescendantByIndex`, `$getNodeByKey` and `$getNodeByKeyOrThrow` from the TypeScript declarations and, in the same release, from the hand-maintained Flow declarations in `packages/lexical/flow/Lexical.js.flow`. TypeScript carried those overloads as `@deprecated` for several releases before removing them, so a TypeScript codebase was told in its editor long before the call sites stopped checking. Flow has no deprecation signal: the `@deprecated` tag on a `.js.flow` declaration is a comment and nothing reads it, so for Flow this was a removal with no notice at all. Every call site that passes a type argument fails at once with `nonpolymorphic-type-arg`, and the `prop-missing` and `incompatible-type` errors that follow where the cast was load-bearing. The upgrade has no codemod, by design — each site needs the guard that fits its context — so a large Flow codebase cannot cross this in one step. Restore the overloads in the Flow declarations only, still `@deprecated`, with the comment saying that the TypeScript overload is gone and that these stay until the remaining Flow call sites are migrated. TypeScript is unchanged, the guidance in `traversals.md` is unchanged, and new code in either language should call these methods without a type argument and narrow the result with a node guard. ## Test plan ### Before `flow check` over Meta's www Flow root with v0.53.0's declarations in place (paths redacted): ``` Error --------------------------------------------------------------------- <redacted>/SomeLayoutPlugin.js:129:26 Cannot call non-polymorphic `() => Array<LexicalNode>` [1] with type arguments. [nonpolymorphic-type-arg] 129| const children = node.getChildren<LexicalNode>(); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ References: html/shared/lexical/Lexical.js.flow:974:3 974| getChildren(): LexicalNode[]; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1] Found 2174 errors ``` ### After The same root, same revision, with this change applied to `Lexical.js.flow`: ``` $ flow check . No errors! real 10m6.650s ``` The OSS checks were not run in this environment (its package manager is not available there); CI runs `pnpm run ci-check` on this PR.
potatowagon
requested review from
acywatson,
etrepum,
ivailop7 and
zurfyx
as code owners
October 29, 2026 15:30
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
lexical
@lexical/a11y
@lexical/clipboard
@lexical/code
@lexical/code-core
@lexical/code-prism
@lexical/code-shiki
@lexical/compiler
@lexical/devtools-core
@lexical/dragon
@lexical/eslint-plugin
@lexical/extension
@lexical/fast-check
@lexical/file
@lexical/hashtag
@lexical/headless
@lexical/history
@lexical/html
@lexical/internal
@lexical/link
@lexical/list
@lexical/mark
@lexical/markdown
@lexical/mdast
@lexical/offset
@lexical/overflow
@lexical/plain-text
@lexical/react
@lexical/rich-text
@lexical/selection
@lexical/table
@lexical/tailwind
@lexical/text
@lexical/utils
@lexical/y
@lexical/yjs
commit: |
etrepum
approved these changes
Oct 29, 2026
zurfyx
added a commit
that referenced
this pull request
Nov 2, 2026
…s in CHANGELOG.md by the call shapes they break, and add the missing v0.48 list Backspace behavior change ## Description Three backfilled CHANGELOG.md entries did not tell people upgrading who is affected or what to change: - v0.46.0, #8661: the breaking entry said traversal methods "return the base node type" and only named annotated assignments. It did not say that the methods (and `$getNodeByKey` / `$getNodeByKeyOrThrow`) gained a non-generic first overload, so a call without a type argument that used to infer `T` from where its result went (a function argument, a return value, an annotated variable or array) now returns `LexicalNode` and stops compiling. Detect now names those call shapes and the TypeScript error, Migration shows the function-argument case, and the matching deprecation entry now has its own Detect and says the overloads were removed from TypeScript in v0.53.0 (#9479), while the Flow declarations keep them after #9529, instead of "Removal: not scheduled". - v0.49.0, #8877: the entry said `LexicalCommand<T>` is invariant, but Detect only named `LexicalCommand<unknown>` and explicit generics. A `registerCommand` listener whose parameter annotation is narrower or wider than the payload (for example `(event: KeyboardEvent) => ...` for `KEY_ENTER_COMMAND`, whose payload is `KeyboardEvent | null`), or a helper typed `LexicalCommand<KeyboardEvent>` called with that command, also stops compiling. Detect lists these shapes and the error, and Migration shows inferred listeners and a generic helper. - v0.48.0, #8829: not listed at all. `registerList` handles Backspace at `COMMAND_PRIORITY_BEFORE_EDITOR`, before rich text: at the start of a top-level item it turns the item into a paragraph and splits the list, where it used to join it to the item above. It is now a behavior change with a Verify line. `ListItemNode.collapseAtStart` also widened its return type from `true` to `boolean`; the entry says why that is not filed as breaking. To keep this from recurring, `.changeset/README.md` gets a "Type signature changes" section: a type change that can make existing call sites stop compiling is `[breaking]` even when it only deprecates something, and its Detect names the call shapes, including callers that rely on an inferred type argument. AGENTS.md and CONTRIBUTING.md, which already summarize the changeset format, get one paragraph each. `pnpm run check-changesets` now warns (without failing) when a `[deprecation]` or `[chore]` entry mentions a type parameter, overload, generic, return or payload type, or signature and has no `Detect:` paragraph. The pattern also covers "type params", "branded", "invariant", "narrowed return/payload" and "now returns". Neither the pending changesets nor the curated `[deprecation]` and Other entries in CHANGELOG.md trigger it. Out of scope: `packages/lexical-list/flow/LexicalList.js.flow` still declares `collapseAtStart(selection: RangeSelection): true`. Changing it is a published Flow type change that needs its own changeset. ## Changeset None needed: documentation and changeset tooling only. ## Test plan The new CHANGELOG.md wording was checked against the declarations at the v0.45.0, v0.46.0, v0.48.0 and v0.49.0 tags, and the TypeScript errors and the Migration snippets were compiled against the current sources. The list Backspace change was checked with a scratch unit test (not committed) that presses Backspace at the start of the second of three items, with and without `ListExtension`: `["list:first","paragraph:second","list:third"]` with it, and `["list:firstsecond|third"]` with rich text alone, which is what v0.47 did. ### Before With the test changes applied but not the CHANGELOG.md and `entry.mjs` changes: ``` $ pnpm vitest run scripts/__tests__/unit/changesets.test.ts scripts/__tests__/unit/changelog.test.ts × warns when a deprecation or chore changes types without Detect 4ms × parses the repository CHANGELOG.md 15ms FAIL |scripts-unit| scripts/__tests__/unit/changelog.test.ts > parseChangelog > parses the repository CHANGELOG.md AssertionError: expected { behavior: 43, breaking: 35, …(1) } to deeply equal { behavior: 44, breaking: 35, …(1) } FAIL |scripts-unit| scripts/__tests__/unit/changesets.test.ts > changeset entry format > warns when a deprecation or chore changes types without Detect AssertionError: expected { errors: [], warnings: [] } to deeply equal { errors: [], warnings: [ …(1) ] } Test Files 2 failed (2) Tests 2 failed | 63 passed (65) ``` ### After ``` $ pnpm vitest run scripts/__tests__/unit/changesets.test.ts scripts/__tests__/unit/changelog.test.ts Test Files 2 passed (2) Tests 65 passed (65) $ pnpm run check-changesets Changeset check passed: 80 pending changeset(s) valid. ``` Prettier and ESLint pass on the changed files.
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.
Description
v0.53.0 (#9479) removed the unchecked type-argument overloads of
getParent,getParentOrThrow,getParents,getPreviousSibling,getPreviousSiblings,getNextSibling,getNextSiblings,getChildren,getFirstChild,getFirstChildOrThrow,getLastChild,getLastChildOrThrow,getChildAtIndex,getFirstDescendant,getLastDescendant,getDescendantByIndex,$getNodeByKeyand$getNodeByKeyOrThrowfrom theTypeScript declarations and, in the same release, from the hand-maintained
Flow declarations in
packages/lexical/flow/Lexical.js.flow.TypeScript carried those overloads as
@deprecatedfor several releasesbefore removing them, so a TypeScript codebase was told in its editor long
before the call sites stopped checking. Flow has no deprecation signal: the
@deprecatedtag on a.js.flowdeclaration is a comment and nothing readsit, so for Flow this was a removal with no notice at all. Every call site that
passes a type argument fails at once with
nonpolymorphic-type-arg, plus theprop-missingandincompatible-typeerrors that follow wherever the castwas load-bearing. The upgrade has no codemod, by design — each site needs the
guard that fits its context — so a large Flow codebase cannot cross this in
one step, and the Meta www sync that imports v0.53.0 is blocked on 2,174 such
errors.
This restores the overloads in the Flow declarations only, still
@deprecated, with the comment now saying that the TypeScript overload isgone and that these stay until the remaining Flow call sites are migrated.
TypeScript is unchanged,
traversals.mdis unchanged, and new code in eitherlanguage should call these methods without a type argument and narrow the
result with a node guard.
Changeset
.changeset/restore-flow-unchecked-node-type-arguments.md—[fix]onlexical, since the shipped Flow types change for consumers.Test plan
Before
flow checkover Meta's www Flow root with v0.53.0's declarations in place(paths redacted):
After
The same root at the same revision, with this change applied to its copy of
Lexical.js.flow:The repository's own checks were not run in this environment (its package
manager is unavailable there); CI runs
pnpm run ci-checkon this PR.