Skip to content

[lexical] Bug Fix: Keep the deprecated unchecked node type arguments in the Flow declarations - #9529

Merged
etrepum merged 1 commit into
mainfrom
flow-keep-unchecked-node-type-args
Oct 29, 2026
Merged

etrepum merged 1 commit into
mainfrom
flow-keep-unchecked-node-type-args

Conversation

@potatowagon

Copy link
Copy Markdown
Contributor

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, plus the
prop-missing and incompatible-type errors that follow wherever 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, 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 is
gone and that these stay until the remaining Flow call sites are migrated.
TypeScript is unchanged, 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.

Changeset

.changeset/restore-flow-unchecked-node-type-arguments.md — [fix] on
lexical, since the shipped Flow types change for consumers.

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 at the same revision, with this change applied to its copy of
Lexical.js.flow:

$ flow check .
No errors!

real	10m6.650s

The repository's own checks were not run in this environment (its package
manager is unavailable there); CI runs pnpm run ci-check on this PR.

…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.
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Oct 29, 2026 3:31pm UTC
lexical-playground Ready Ready Preview Oct 29, 2026 3:31pm UTC

Request Review

@meta-cla meta-cla 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 Oct 29, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 29, 2026

Copy link
Copy Markdown
lexical

npm i https://pkg.pr.new/lexical@9529

@lexical/a11y

npm i https://pkg.pr.new/@lexical/a11y@9529

@lexical/clipboard

npm i https://pkg.pr.new/@lexical/clipboard@9529

@lexical/code

npm i https://pkg.pr.new/@lexical/code@9529

@lexical/code-core

npm i https://pkg.pr.new/@lexical/code-core@9529

@lexical/code-prism

npm i https://pkg.pr.new/@lexical/code-prism@9529

@lexical/code-shiki

npm i https://pkg.pr.new/@lexical/code-shiki@9529

@lexical/compiler

npm i https://pkg.pr.new/@lexical/compiler@9529

@lexical/devtools-core

npm i https://pkg.pr.new/@lexical/devtools-core@9529

@lexical/dragon

npm i https://pkg.pr.new/@lexical/dragon@9529

@lexical/eslint-plugin

npm i https://pkg.pr.new/@lexical/eslint-plugin@9529

@lexical/extension

npm i https://pkg.pr.new/@lexical/extension@9529

@lexical/fast-check

npm i https://pkg.pr.new/@lexical/fast-check@9529

@lexical/file

npm i https://pkg.pr.new/@lexical/file@9529

@lexical/hashtag

npm i https://pkg.pr.new/@lexical/hashtag@9529

@lexical/headless

npm i https://pkg.pr.new/@lexical/headless@9529

@lexical/history

npm i https://pkg.pr.new/@lexical/history@9529

@lexical/html

npm i https://pkg.pr.new/@lexical/html@9529

@lexical/internal

npm i https://pkg.pr.new/@lexical/internal@9529

@lexical/link

npm i https://pkg.pr.new/@lexical/link@9529

@lexical/list

npm i https://pkg.pr.new/@lexical/list@9529

@lexical/mark

npm i https://pkg.pr.new/@lexical/mark@9529

@lexical/markdown

npm i https://pkg.pr.new/@lexical/markdown@9529

@lexical/mdast

npm i https://pkg.pr.new/@lexical/mdast@9529

@lexical/offset

npm i https://pkg.pr.new/@lexical/offset@9529

@lexical/overflow

npm i https://pkg.pr.new/@lexical/overflow@9529

@lexical/plain-text

npm i https://pkg.pr.new/@lexical/plain-text@9529

@lexical/react

npm i https://pkg.pr.new/@lexical/react@9529

@lexical/rich-text

npm i https://pkg.pr.new/@lexical/rich-text@9529

@lexical/selection

npm i https://pkg.pr.new/@lexical/selection@9529

@lexical/table

npm i https://pkg.pr.new/@lexical/table@9529

@lexical/tailwind

npm i https://pkg.pr.new/@lexical/tailwind@9529

@lexical/text

npm i https://pkg.pr.new/@lexical/text@9529

@lexical/utils

npm i https://pkg.pr.new/@lexical/utils@9529

@lexical/y

npm i https://pkg.pr.new/@lexical/y@9529

@lexical/yjs

npm i https://pkg.pr.new/@lexical/yjs@9529

commit: 7ee6944

@etrepum
etrepum added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit 4d081c5 Oct 29, 2026
57 of 58 checks passed
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

2 active deployments
Preview – lexical — 7ee6944e Deployed Oct 29, 2026 by vercel[bot]
Preview – lexical-playground — 7ee6944e Deployed Oct 29, 2026 by vercel[bot]
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.

2 participants