Repository navigation
Conversation
Hooks that spread their remaining props, and the private `PolymorphicIntrinsicProps` type, had no name TypeScript could reference, so the emitted declarations inlined every DOM attribute from the `@types/react` version used at build time. Since the React 19 upgrade, that put React 19-only types (`SubmitEventHandler`, `ToggleEventHandler`, the two-parameter `ChangeEventHandler`) into the published declarations, which fail to type-check with `@types/react` 18 despite the `^18 || ^19` peer ranges. - Add a `HookReturnProps` helper type and give each affected hook an explicit return type built on `WordPressComponentProps`. - Export `PolymorphicIntrinsicProps` so `contextConnect` declarations reference it by name. - Declare `RawHTML`'s return type as `React.ReactElement`. See WordPress#84464.
🤖 PR meta 🤖🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
yyppsk
force-pushed
the
fix/react-18-type-declarations
branch
from
October 11, 2026 17:24
257b6f8 to
925d946
Compare
This branch has not been 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.
What?
Fixes the published type declarations of
@wordpress/componentsand@wordpress/elementso they type-check with@types/react18 again.Closes #84464
Why?
The packages' peer ranges allow
@types/react^18 || ^19, but since the React 19 upgrade their.d.tsfiles reference React 19-only types (SubmitEventHandler,ToggleEventHandler, and the two-parameterChangeEventHandler<T, U>). A React 18 consumer usingskipLibCheck: falsegets ~180 errors from@wordpress/components@42.Hooks that destructure
...otherPropsand spread them into their return value have no nameable return type, so TypeScript writes every DOM attribute from the@types/reactversion used at build time into the declarations. The privatePolymorphicIntrinsicPropstype is inlined the same way into everycontextConnectcomponent (e.g.BaseControl), and so isRawHTML's inferredcreateElementreturn type.How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Use of AI Tools
Exact this MD with solution approach, and follow exact md given here