Skip to content

[lexical] Breaking Change: Remove deprecated unchecked node type arguments - #9479

Merged
etrepum merged 7 commits into
meta:mainfrom
etrepum:codex/remove-deprecated-unsafe-generics
Oct 28, 2026
Merged

etrepum merged 7 commits into
meta:mainfrom
etrepum:codex/remove-deprecated-unsafe-generics

Conversation

@etrepum

@etrepum etrepum commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Remove deprecated unchecked generic overloads from node traversal and key lookup APIs in TypeScript and Flow. The non-generic methods and runtime behavior are unchanged.

Update internal callers and existing tests to use base node types or narrow results with node guards. Callers should remove explicit type arguments and check the returned node before accessing subclass-specific methods. Safe generics whose inputs establish the result type remain supported.

Remove obsolete documentation and stale source comments while retaining examples of supported calls.

Test plan

Before

Traversal and key lookup overloads allowed callers to claim an arbitrary node subclass without checking the result.

After

  • Source, test and website TypeScript checks pass.
  • Flow passes with no errors.
  • The existing LexicalNode unit suite passes all 135 tests.
  • ESLint, Prettier, package build, documentation build and documentation examples pass.
  • CI at 7e0eb0e passed integrity checks, Node 22/24 unit suites and Chromium browser tests. Integrity includes website builds and embedded example checks.

… change: Remove deprecated unchecked node type arguments

## Description

Deprecated traversal and key lookup overloads let callers claim an arbitrary node subclass without checking it. Remove those unchecked type arguments while preserving every non-generic method and its runtime behavior.

Inventory across the packages:
- `LexicalNode`: `getParent`, `getParentOrThrow`, `getPreviousSibling(s)`, and `getNextSibling(s)`.
- `ElementNode`: `getChildren`, `getChildAtIndex`, `getFirstChild`/`getLastChild` (including `OrThrow`), `getFirstDescendant`/`getLastDescendant`, and `getDescendantByIndex`.
- Lookup helpers: `$getNodeByKey` and `$getNodeByKeyOrThrow`.
- Flow additionally loses its deprecated generic `getParents` and array-type `getChildren` overload. In total: 17 TypeScript overloads and 19 Flow overloads.

Retain deprecated `@lexical/utils`'s `$filter<T>` and `@lexical/selection`'s `$cloneWithProperties<T>` re-export: their callback/input establishes the result type. Preserve safe self/subclass APIs such as `getLatest`, `getWritable`, cloning, replacement, factory/predicate-based generics, and NodeCaret origin types. Unrelated deprecations are outside this change.

**Migration:** remove explicit type arguments, then narrow with a concrete guard such as `$isTextNode` or `$isTableCellNode`; filter collections with a guard when selecting a subtype. `OrThrow` establishes existence, not the subclass. Updated all affected internal/test callers using guards or existing base methods, added negative and positive TypeScript/Flow coverage, and documented the migration in the traversal guide. Source declarations generate the published TypeScript declarations; hand-maintained Flow declarations are updated directly.

This branch is independent of Chrome Web Store deployment changes.

## Test plan

### Before

With the new negative type coverage and the old signatures:

```text
$ pnpm --config.verify-deps-before-run=false run tsc-test
packages/lexical/src/__tests__/unit/LexicalNode.test.ts(3308,7): error TS2578: Unused '@ts-expect-error' directive.
packages/lexical/src/__tests__/unit/LexicalNode.test.ts(3310,7): error TS2578: Unused '@ts-expect-error' directive.
[ELIFECYCLE] Command failed with exit code 2.
```

There were 17 unused directives, one for each deprecated TypeScript overload. Running the Flow fixture against the base declarations with `flow full-check --include-warnings` reports 24 warnings: 19 unused negative-test suppressions plus 5 existing warnings.

### After

```text
$ pnpm --config.verify-deps-before-run=false run test-unit
 Test Files  380 passed (380)
      Tests  9281 passed | 1 skipped (9282)

$ pnpm --config.verify-deps-before-run=false exec vitest --project unit --no-watch packages/lexical/src/__tests__/unit/LexicalNode.test.ts
 Test Files  1 passed (1)
      Tests  135 passed (135)

$ pnpm --config.verify-deps-before-run=false exec vitest --config /tmp/lexical-system-chromium.config.mjs --project browser --no-watch packages/lexical-table/src/__tests__/browser/EmptyCellTouchSelection.test.ts
 Test Files  1 passed (1)
      Tests  30 passed (30)

$ pnpm --config.verify-deps-before-run=false run flow
Running Flow...
Found 0 errors
```

All TypeScript checks in `ci-check` (source, tests, scripts, devtools, website), formatting, `build-types`, and `build` passed. Verified the generated public declarations have no removed generics, and TypeScript emission of all three modified core source files is identical to the base. Final `flow full-check --include-warnings` reports only the same 5 pre-existing warnings; every new negative-test suppression is used.

Local limitations/baseline findings:
- `ci-check`'s ESLint step encounters the environment's pre-existing ignored `playwright.local.config.mjs` (missing copyright header). `pnpm --config.verify-deps-before-run=false run lint --ignore-pattern playwright.local.config.mjs` passes. That local file is untouched and absent from the PR.
- `lint-flow` fails with 328 pre-existing export-parity warnings. A detached checkout of the base commit produces the same 328 messages, ignoring shifted line numbers.
- Playwright's browser download is blocked by HTTP 403 (`Domain forbidden`). The modified browser tests passed using installed Chromium 151 through a temporary config that only sets `launchOptions.executablePath`. Firefox, WebKit, the full browser suite, and E2E suites were not run.
@vercel

vercel Bot commented Oct 27, 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 28, 2026 3:40am UTC
lexical-playground Ready Ready Preview Oct 28, 2026 3:40am 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 27, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
lexical

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

@lexical/a11y

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

@lexical/clipboard

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

@lexical/code

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

@lexical/code-core

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

@lexical/code-prism

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

@lexical/code-shiki

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

@lexical/compiler

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

@lexical/devtools-core

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

@lexical/dragon

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

@lexical/eslint-plugin

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

@lexical/extension

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

@lexical/fast-check

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

@lexical/file

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

@lexical/hashtag

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

@lexical/headless

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

@lexical/history

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

@lexical/html

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

@lexical/internal

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

@lexical/link

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

@lexical/list

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

@lexical/mark

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

@lexical/markdown

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

@lexical/mdast

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

@lexical/offset

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

@lexical/overflow

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

@lexical/plain-text

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

@lexical/react

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

@lexical/rich-text

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

@lexical/selection

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

@lexical/table

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

@lexical/tailwind

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

@lexical/text

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

@lexical/utils

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

@lexical/yjs

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

commit: 3c7e94d

…l-table][lexical-yjs] Chore: Migrate new test callers from unchecked generics

## Description

Tests added on main still supplied removed unchecked traversal type arguments. Use base node return types where sufficient and existing guarded assertions where concrete node methods are required. Preserve the existing test behavior without restoring unsafe APIs or adding tests.

## Test plan

### Before

`pnpm run tsc`:

```
packages/lexical-extension/src/__tests__/unit/BlockIdExtension.test.ts(1093,49): error TS2558: Expected 0 type arguments, but got 1.
packages/lexical-extension/src/__tests__/unit/BlockIdExtension.test.ts(1094,25): error TS2339: Property 'getFirstDescendant' does not exist on type 'LexicalNode'.
[ELIFECYCLE] Command failed with exit code 2.
```

### After

`pnpm run tsc` (exit 0):

```
$ tsc
```

`pnpm run tsc-test` (exit 0):

```
$ tsc -p ./tsconfig.test.json
```

`git diff --name-only -z | xargs -0 pnpm exec eslint` (exit 0; no output).

`git diff --name-only -z | xargs -0 pnpm exec prettier --check`:

```
Checking formatting...
All matched files use Prettier code style!
```

`git diff --check` (exit 0; no output).

No runtime or browser suites were rerun for this test-only caller migration.
…e: Remove obsolete traversal documentation and rejection tests

## Description

Remove the removed-overload example and migration inventory from the traversal guide, retaining supported guard examples. Remove stale source comments and reword historical changelog entries while preserving PR attribution. Delete the newly added Flow fixture and rejected-generic TypeScript assertions; keep existing traversal coverage, supported-call migrations, and runtime APIs unchanged.

## Test plan

### Before

Documentation/comment audit at the previous head:

```text
packages/lexical-website/docs/concepts/traversals.md:20: getFirstChild<
packages/lexical/src/LexicalNode.ts:1293: deprecated generic signatures from meta#8661
```

### After

Documentation/comment audit of all tracked text files:

```text
Scanned 2514 tracked text files, 191 documentation files, 31508 source comment blocks.
No removed traversal signatures or obsolete deprecation references remain in documentation or source comments.
```

`pnpm run tsc-test`, `pnpm run tsc`, and `pnpm run tsc-website` (exit 0):

```text
$ tsc -p ./tsconfig.test.json
$ tsc
$ tsc -p tsconfig.json
```

`pnpm run flow` (exit 0):

```text
Running Flow...
Found 0 errors
```

`pnpm exec vitest --project unit --no-watch packages/lexical/src/__tests__/unit/LexicalNode.test.ts`:

```text
 Test Files  1 passed (1)
      Tests  135 passed (135)
```

`pnpm run build` and `pnpm run build:doc-examples` (exit 0):

```text
Built 5 documentation examples.
```

`pnpm run build-docs` (exit 0; existing TypeDoc, bundle, and static-generation warnings):

```text
[SUCCESS] Generated static files in "build".
```

Changed-file ESLint and `git diff --check`: exit 0.
Changed-file Prettier (Markdown is excluded by the repository configuration):

```text
Checking formatting...
All matched files use Prettier code style!
```

No new tests added. Full browser/E2E suites not rerun locally.
## Description

Restore the two historical changelog entries changed by the documentation cleanup. Release history remains unchanged; keep all current documentation, stale-source-comment, and redundant-test cleanup intact.

## Test plan

### Before

`git diff HEAD^ HEAD -- CHANGELOG.md` showed two historical entries rewritten by the previous commit.

### After

`git diff --exit-code a09a11e -- CHANGELOG.md` (exit 0; no output).

`git diff --check` (exit 0; no output).

Only two Markdown lines restored. No code or documentation guidance changed; no broad tests rerun for this restoration.
@etrepum
etrepum added this pull request to the merge queue Oct 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 27, 2026
@etrepum
etrepum added this pull request to the merge queue Oct 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 28, 2026
…ore: Sync main and narrow clipboard test nodes

## Description

Merge upstream main at e7baf73. The four clipboard browser fixtures introduced there use unchecked traversal type arguments, which fail against this branch. Narrow their text nodes with $isTextNode and the existing Vitest assertion before selecting text.

## Test plan

### Before

`pnpm --config.verify-deps-before-run=false run tsc-test`:

```text
$ tsc -p ./tsconfig.test.json
packages/lexical-plain-text/src/__tests__/browser/PlainTextDecoratorInputClipboard.test.ts(76,37): error TS2558: Expected 0 type arguments, but got 1.
packages/lexical-plain-text/src/__tests__/browser/PlainTextDecoratorInputClipboard.test.ts(76,50): error TS2339: Property 'select' does not exist on type 'LexicalNode'.
packages/lexical-plain-text/src/__tests__/browser/PlainTextUnmanagedInputClipboard.test.ts(75,37): error TS2558: Expected 0 type arguments, but got 1.
packages/lexical-plain-text/src/__tests__/browser/PlainTextUnmanagedInputClipboard.test.ts(75,50): error TS2339: Property 'select' does not exist on type 'LexicalNode'.
packages/lexical-rich-text/src/__tests__/browser/RichTextDecoratorInputClipboard.test.ts(76,37): error TS2558: Expected 0 type arguments, but got 1.
packages/lexical-rich-text/src/__tests__/browser/RichTextDecoratorInputClipboard.test.ts(76,50): error TS2339: Property 'select' does not exist on type 'LexicalNode'.
packages/lexical-rich-text/src/__tests__/browser/RichTextUnmanagedInputClipboard.test.ts(75,37): error TS2558: Expected 0 type arguments, but got 1.
packages/lexical-rich-text/src/__tests__/browser/RichTextUnmanagedInputClipboard.test.ts(75,50): error TS2339: Property 'select' does not exist on type 'LexicalNode'.
[ELIFECYCLE] Command failed with exit code 2.
```

### After

`pnpm --config.verify-deps-before-run=false run tsc-test` exits 0:

```text
$ tsc -p ./tsconfig.test.json
```

The existing integrity run reported no TypeScript or formatting errors. Flow passed:

```text
Running Flow...
Found 0 errors
```

Stock `ci-check` encounters the saved environment's ignored, untracked `playwright.local.config.mjs` (missing copyright header). `pnpm --config.verify-deps-before-run=false run lint --ignore-pattern playwright.local.config.mjs` exits 0:

```text
$ eslint ./ --ignore-pattern playwright.local.config.mjs
```

Browser and E2E suites were not run locally.
## Description

A fresh standalone install resolves the example's direct Zag dependency to 1.47 while Ark's combobox uses 1.45. Typing Ark's selection callback with the separate Zag type requires a modifiers field that Ark does not provide. Use Ark's exported Combobox.SelectionDetails and remove the unused direct Zag dependency.

Apply the two-file fix from 6d551bc without other changes from that branch.

## Test plan

### Before

Integration CI on f9fb5fd reported:

```text
src/plugins/StyleViewPlugin.tsx(654,5): error TS2322
Property 'modifiers' is missing in type '...@[email protected]' but required in type '...@[email protected]'.
Test Files  1 failed | 6 passed (7)
Tests  633 passed | 2 skipped (635)
```

### After

With Node 24 and pnpm 11.24.0, run the existing focused integration harness, building release tarballs from scratch and performing the example's fresh install and build:

```text
$ pnpm --config.verify-deps-before-run=false exec vitest run --project integration scripts/__tests__/integration/prepare-release.test.mjs -t examples/node-state-style
Test Files  1 passed (1)
Tests  2 passed | 98 skipped (100)
```

Changed-file ESLint and Prettier pass:

```text
$ pnpm --config.verify-deps-before-run=false exec eslint examples/node-state-style/src/plugins/StyleViewPlugin.tsx
$ pnpm --config.verify-deps-before-run=false exec prettier --check examples/node-state-style/package.json examples/node-state-style/src/plugins/StyleViewPlugin.tsx
Checking formatting...
All matched files use Prettier code style!
```

The full integration matrix was not rerun locally.
@etrepum
etrepum added this pull request to the merge queue Oct 28, 2026
Merged via the queue into meta:main with commit 8a573d1 Oct 28, 2026
80 of 81 checks passed
zurfyx added a commit that referenced this pull request Oct 28, 2026
## Description

#9479 merged after the changesets in this PR were written. This adds its
`[breaking]` entry, with `Migration:` and `Detect:`, so v0.53.0 lists it
under Breaking changes.

## Test plan

### After

```
$ pnpm run check-changesets
Changeset check passed: 55 pending changeset(s) valid.
```
@zurfyx zurfyx mentioned this pull request Oct 28, 2026
AlessioGr added a commit to payloadcms/payload that referenced this pull request Oct 28, 2026
_Written with AI_

Upgrades  lexical from `0.52.0` to `0.53.0`.

## Breaking changes

Rich-text data keeps its existing format. No database migration is
needed. Payload's built-in features have been updated, but your own
TypeScript code or custom features may need changes:

- **Node type arguments:** `getParent<T>()`, `getParentOrThrow<T>()`,
`getChildren<T>()`, `getFirstChild<T>()`, `getNextSibling<T>()`,
`$getNodeByKey<T>()` and the rest of that family no longer accept a type
argument. Remove `<T>` and narrow the result with a node guard such as
`$isListItemNode`. Runtime behavior is unchanged.
- **Removed extensions:** `LinkImportExtension`, `ListImportExtension`,
`RichTextImportExtension` and `HorizontalRuleImportExtension`
(deprecated in 0.52) are no longer exported from
`@payloadcms/richtext-lexical/lexical/link`, `/list`, `/rich-text` and
`/html`. Use `LinkExtension`, `ListExtension` and `RichTextExtension`;
for horizontal rules, use `HorizontalRuleExtension` from
`@lexical/extension`.
- **Markdown export:** `convertLexicalToMarkdown` escapes literal
brackets and HTML-like text, for example `[note]` becomes
`&#91;note&#93;`, so it is not parsed back as a link or HTML.
`convertMarkdownToLexical` restores the original text.

## Breaking changes and Payload migrations

Reviewed [0.53.0](https://github.com/meta/lexical/releases/tag/v0.53.0)
and the `CHANGELOG.md` now shipped in the `lexical` package, including
its behavior changes. **Yes** means Payload code needed adaptation;
**No** means no Payload migration was required.

| Breaking change | Required migration in Payload | Changes made |
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| ----------------------------- |
---------------------------------------------------------------------------------------------------------------------------------------------------
|
| [Unchecked node type arguments are
removed](meta/lexical#9479) from traversal
and key lookup methods. | Yes | `TableCellResizerPlugin` called
`tableRow.getChildren<TableCellNode>()`. It now uses
`.filter($isTableCellNode)`, matching the upstream playground. |
| [Extensions deprecated in 0.52 are
removed](meta/lexical#9316). | No | Payload
does not use them. They disappear from the `export *` proxies listed
above. |
| [`ElementNode.reconcileObservedMutation` restores the committed
children's DOM](meta/lexical#9329)
(`@internal`). | No | No Payload call sites. |
| [`@lexical/mdast` stores table column alignment as cell paragraph
format](meta/lexical#9478). | No | Payload
does not use `@lexical/mdast`. |
| Behavior: [Markdown export escapes literal
text](meta/lexical#9481). | No | Documented
in the migration guide. MDX round-trip int tests pass unchanged. |
| Behavior: [a read-only `ContentEditable` without an accessible name no
longer renders
`role="textbox"`](meta/lexical#9270). | No |
Payload passes the field label as `aria-label`, so labeled read-only
editors keep the role. |
| Behavior: [`ClickableLinkPlugin` opens new tabs without
`window.opener`](meta/lexical#9303), and
[nested editors handle their own link
clicks](meta/lexical#9360). | No | The link
feature uses `ClickableLinkPlugin` and gets the reverse-tabnabbing fix
automatically. |

Package entry points of every proxied package were compared against
0.52.0. The only addition is the experimental
`@lexical/html/BlockIdHTMLExtension` subpath. Payload only re-exports
the `@lexical/html` root, so no proxy exports need adding or removing.

## Previous Lexical upgrades

- [#18397](#18397) — 0.50.0 →
0.52.0
- [#18149](#18149) — 0.48.0 →
0.50.0
- [#17554](#17554) — 0.45.0 →
0.48.0
SujinKim1127 added a commit to SujinKim1127/lexical that referenced this pull request Oct 29, 2026
…overlay test

## Description

`main` removed the deprecated unchecked type arguments on node getters
(meta#9479), so `getFirstChildOrThrow<ElementNode>()` in
`IosEmptyCellOverlay.test.ts` no longer type-checks and the `integrity` CI
job failed on this PR. The test now gets a cell's paragraph through a small
`$paragraph()` helper that narrows with `$isElementNode` and `assert`.

## Test plan

### Before

With `main` merged into the branch:

```
$ pnpm run tsc
packages/lexical-table/src/__tests__/unit/IosEmptyCellOverlay.test.ts(72,33): error TS2558: Expected 0 type arguments, but got 1.
packages/lexical-table/src/__tests__/unit/IosEmptyCellOverlay.test.ts(73,12): error TS2339: Property 'append' does not exist on type 'LexicalNode'.
packages/lexical-table/src/__tests__/unit/IosEmptyCellOverlay.test.ts(199,39): error TS2558: Expected 0 type arguments, but got 1.
packages/lexical-table/src/__tests__/unit/IosEmptyCellOverlay.test.ts(199,54): error TS2339: Property 'clear' does not exist on type 'LexicalNode'.
packages/lexical-table/src/__tests__/unit/IosEmptyCellOverlay.test.ts(246,33): error TS2558: Expected 0 type arguments, but got 1.
packages/lexical-table/src/__tests__/unit/IosEmptyCellOverlay.test.ts(247,12): error TS2339: Property 'append' does not exist on type 'LexicalNode'.
```

### After

Each `ci-check` step run on its own (`tsc`, `tsc-test`, `tsc-scripts`,
`tsc-extension`, `tsc-website`, `flow`, `prettier`, `lint`,
`check-changesets`): all exit 0.

```
$ pnpm exec vitest run packages/lexical-table
 Test Files  31 passed (31)
      Tests  298 passed (298)
$ pnpm exec vitest run --project browser packages/lexical-table/src/__tests__/browser
      Tests  58 passed (58)
$ pnpm exec vitest run scripts/__tests__/unit/treeShakingSource.test.ts
      Tests  374 passed (374)
```

Co-Authored-By: Claude Opus 5.5 <[email protected]>
potatowagon added a commit that referenced this pull request Oct 29, 2026
…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.
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.
rinarakaki added a commit to rinarakaki/lexical that referenced this pull request Nov 20, 2026
…, and add its changeset

## Description

`isCaretInView` in `Issue9279SlotCaretScrollIntoView.test.ts` required the caret's line to lie exactly inside the root's box. Firefox, and WebKit on macOS, lay the lines out on half pixels while `scrollTop` is whole, so a line scrolled to the bottom edge ends at 150.5px against an edge at 150px, and all three cases failed there, the root's own text included. The check now allows 1px either way, as `CodeBlockCaretScroll.test.ts` allows Firefox's half pixel.

Also, after merging `main`:
- `$getNodeByKey` takes no type argument since meta#9479, so the test calls it without one;
- the changeset for the fix.

## Changeset

`.changeset/slot-caret-scroll-into-view.md`

## Test plan

### Before

`VITEST_BROWSER=chromium,firefox,webkit pnpm exec vitest --project browser --no-watch --reporter=verbose packages/lexical/src/__tests__/browser/Issue9279SlotCaretScrollIntoView.test.ts` (file and describe prefix trimmed):

```
 ✓ |browser (chromium)| scrolls to a caret in the root's own text far below 19ms
 ✓ |browser (chromium)| scrolls to a caret in a named slot's text far below 6ms
 ✓ |browser (chromium)| scrolls to a caret in an editable island's text far below 4ms
 ✓ |browser (webkit)| scrolls to a caret in the root's own text far below 39ms
 ✓ |browser (webkit)| scrolls to a caret in a named slot's text far below 30ms
 ✓ |browser (webkit)| scrolls to a caret in an editable island's text far below 11ms
 × |browser (firefox)| scrolls to a caret in the root's own text far below 134ms
 × |browser (firefox)| scrolls to a caret in a named slot's text far below 36ms
 × |browser (firefox)| scrolls to a caret in an editable island's text far below 34ms
 Test Files  1 failed | 2 passed (3)
      Tests  3 failed | 6 passed (9)
```

A probe in Firefox read the caret's line at top 129.5, bottom 150.5 against the root's 0 to 150, at `scrollTop` 966. Linux WebKit passes here; CI's macOS WebKit job failed the same three.

### After

The same command:

```
 ✓ |browser (chromium)| scrolls to a caret in the root's own text far below 21ms
 ✓ |browser (chromium)| scrolls to a caret in a named slot's text far below 8ms
 ✓ |browser (chromium)| scrolls to a caret in an editable island's text far below 4ms
 ✓ |browser (webkit)| scrolls to a caret in the root's own text far below 39ms
 ✓ |browser (webkit)| scrolls to a caret in a named slot's text far below 30ms
 ✓ |browser (webkit)| scrolls to a caret in an editable island's text far below 11ms
 ✓ |browser (firefox)| scrolls to a caret in the root's own text far below 25ms
 ✓ |browser (firefox)| scrolls to a caret in a named slot's text far below 11ms
 ✓ |browser (firefox)| scrolls to a caret in an editable island's text far below 8ms
 Test Files  3 passed (3)
      Tests  9 passed (9)
```

With `main`'s `LexicalSelection.ts` and `LexicalUtils.ts`, the slot and island cases still fail in all three engines and the root's passes:

```
 Test Files  3 failed (3)
      Tests  6 failed | 3 passed (9)
```

`pnpm run tsc` and `pnpm run check-changesets` pass, and Prettier and ESLint are clean on the changed files. macOS WebKit wasn't run locally.
rinarakaki added a commit to rinarakaki/lexical that referenced this pull request Nov 20, 2026
…eave an arrow key pressed in a node-selected decorator's own input to that input

## Description

When a decorator renders its own `<input>` or `<textarea>` and is node-selected, clicking into that field keeps the editor's NodeSelection, and the field's `keydown` bubbles to the editor's root. Plain text's new NodeSelection branches then called `preventDefault()` and moved the editor's selection beside the node, so the field's caret stopped moving: with the caret after "field" in `field text`, every arrow key left it there, where plain text used to leave these keys to the field. Rich text's NodeSelection branches did the same already.

This change:
- returns `false` from plain text's `$exitNodeSelection`, and skips rich text's four NodeSelection branches, for an event `$isEventFromEmbeddedInput` reports, as the clipboard handlers do since meta#9288;
- adds a browser test to each package that node-selects a decorator holding an input, clicks into the input and presses each arrow key: the keydown isn't prevented, the input's caret lands where the same key puts it in a plain `<input>` outside the editor, and the NodeSelection stays;
- adds right-to-left cases for ArrowLeft and ArrowRight on a node-selected inline decorator, and checks that Shift's RangeSelection holds the rule;
- reworks the TSDoc of `$convertContiguousNodeSelection` to say what it does, including that it commits the caller's update synchronously, and writes `@param name - description` as `AGENTS.md` asks;
- after merging `main`, reads the test's block without `getLastChildOrThrow`'s type argument, which meta#9479 removed;
- adds changesets.

## Changeset

`.changeset/plain-text-node-selection-arrows.md` and `.changeset/selection-node-selection-helpers.md`

## Test plan

### Before

`VITEST_BROWSER=chromium,firefox,webkit pnpm exec vitest --project browser --no-watch --reporter=verbose packages/lexical-plain-text/src/__tests__/browser/PlainTextNodeSelectionArrow.test.ts`, without the guard:

```
 × |browser (chromium)| Arrow keys in the input of a node-selected decorator > ArrowLeft is left to the input
   → expected true to be false // Object.is equality
 × |browser (chromium)| Arrow keys in the input of a node-selected decorator > ArrowRight is left to the input
 × |browser (chromium)| Arrow keys in the input of a node-selected decorator > ArrowUp is left to the input
 × |browser (chromium)| Arrow keys in the input of a node-selected decorator > ArrowDown is left to the input
 (the same four in firefox and webkit, each `expected true to be false`: the keydown was prevented)
 Test Files  3 failed (3)
      Tests  12 failed | 42 passed (54)
```

The same command for `packages/lexical-rich-text/src/__tests__/browser/RichTextNodeSelectionArrow.test.ts`, without rich text's guard (as on `main`):

```
 Test Files  3 failed (3)
      Tests  12 failed | 27 passed (39)
```

### After

Both files, with `PlainTextDecoratorInputClipboard.test.ts` and `RichTextDecoratorInputClipboard.test.ts`, in Chromium, Firefox and WebKit:

```
 Test Files  12 passed (12)
      Tests  135 passed (135)
```

`pnpm exec vitest --project unit --no-watch packages/lexical-plain-text/ packages/lexical-rich-text/ packages/lexical-selection/`:

```
 Test Files  33 passed (33)
      Tests  2104 passed | 1 expected fail (2105)
```

`VITEST_BROWSER=chromium,firefox,webkit pnpm exec vitest --project browser --no-watch packages/lexical-plain-text/ packages/lexical-rich-text/ packages/lexical-selection/`:

```
 Test Files  30 passed (30)
      Tests  237 passed (237)
```

`pnpm run tsc`, `pnpm run flow` and `pnpm run check-changesets` pass, and ESLint and Prettier are clean on the changed files. Only Linux was run; macOS and Windows weren't.

This branch was successfully deployed

2 active deployments
Preview – lexical — 3c7e94dd Deployed Oct 28, 2026 by vercel[bot]
Preview – lexical-playground — 3c7e94dd Deployed Oct 28, 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. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants