Repository navigation
[lexical] Fix: Flow declarations cannot express an extension with dependencies - #9176
Merged
potatowagon merged 1 commit intoSep 17, 2026
Merged
Conversation
…endencies `NormalizedLexicalExtensionArgument` spreads an array into a tuple type, which Flow rejects at the definition site, so `dependencies`, `configExtension` and `buildEditorFromExtensions` are all unusable. `LexicalExtension` is also invariant in `Name`, so no concrete extension is a subtype of `AnyLexicalExtension` and a dependency list holding a real extension is an error. `ReactProviderExtension`, which every React-hosted extension editor must list, is declared nowhere. Adds consumer coverage in the shape of the Lexical.flowtest.js.flow added in 9132: it builds a nested editor from extensions, which is what none of this allowed before.
potatowagon
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7 and
zurfyx
as code owners
September 17, 2026 04:02
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
approved these changes
Sep 17, 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.
Description
The hand-maintained Flow declarations cannot express an extension that has
dependencies, so no Flow codebase can build an editor from extensions — the
defineExtensionfix in #9132 made the function callable, and this is thenext wall behind it. Three separate problems, all of them in the declarations
rather than the runtime:
A dependency list cannot hold anything.
NormalizedLexicalExtensionArgumentis declared as[LexicalExtension<...>, ...Partial<Config>[]]. Flow rejects an arrayspread in a tuple type outright —
Cannot spread non-tuple (array type) into tuple type— so the type is an error at its own definition site, andevery position that uses it (
dependencies,configExtension,buildEditorFromExtensions) fails with it. Spelled as a union of the one-and two-element tuples, it says the same thing in a form Flow accepts.
(An extension takes at most one config override, so the variadic tail was
never meaningful.)
No concrete extension satisfies
AnyLexicalExtension.LexicalExtensionis invariant inName, andAnyLexicalExtensionisLexicalExtension<any, string, any, any>, soLexicalExtension<ReactConfig, '@lexical/react/React', ...>is not asubtype of it:
string is incompatible with string literal '@lexical/react/React'.dependenciesis declared overAnyLexicalExtensionArgument[], so a list holding any real extension is anerror.
Nameis only ever read (readonly name: Name), so marking itcovariant —
out Name extends string— matches TypeScript's behaviour.ReactProviderExtensionis declared nowhere.packages/lexical-react/flow/LexicalReactProviderExtension.js.flowis aheader comment and nothing else, so the import does not resolve. It is not
optional in practice:
ReactExtension.buildinvariants when noReactProviderExtensionpeer is present, so every React-hosted extensioneditor has to list it.
Test plan
pnpm flowpasses (flow full-check, 0 errors, flow-bin 0.331.0).packages/lexical-extension/flow/LexicalExtension.flowtest.js.flow,the same kind of consumer coverage as
packages/lexical/flow/Lexical.flowtest.js.flow([lexical] Fix: make the extension Flow types usable (defineExtension was uncallable) #9132) and for the samereason:
lint-flowcompares exported names andflowchecks thedeclarations are internally consistent, but nothing composes the API the way
an application does, which is how all three of these shipped. It builds a
nested editor from extensions — bare dependency,
configExtensiondependency, inline-tuple dependency,
NestedEditorExtensionconfig, andvariadic
buildEditorFromExtensions.including the definition-site spread error) and passes with them.
declarations through its synced copy: with these three fixes applied, a real
LexicalNestedComposer→NestedEditorExtension+LexicalExtensionEditorComposermigration type-checks, lints, and runs(nested editor builds inside a
DecoratorNodeconstructor, inheritseditablefrom the parent,parentEditorwired). Without them it cannot bewritten at all.
No runtime files are touched.