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

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