fix(react): restore intrinsic HTML props under React 19 types#121
Merged
wangdicoder merged 3 commits intomasterfrom Apr 19, 2026
Merged
fix(react): restore intrinsic HTML props under React 19 types#121wangdicoder merged 3 commits intomasterfrom
wangdicoder merged 3 commits intomasterfrom
Conversation
`React.PropsWithRef<JSX.IntrinsicElements['x']>` relied on the global `JSX` namespace, which @types/react@19 no longer augments. Under React 19 the type collapsed to `any`, silently dropping `onClick`, `type`, `disabled`, `aria-*`, `children`, etc. from every affected component. Replaced with `React.ComponentProps<'x'>` / `React.ComponentPropsWithoutRef<'x'>` across ~60 type files. Works on React 18 and 19. Fixes #120.
The codebase mixed `ComponentProps` (with ref) and `ComponentPropsWithoutRef`
across prop interfaces, all consumed by `React.forwardRef`. Normalize to
`ComponentPropsWithoutRef` throughout — the idiomatic pattern React docs
recommend for forwardRef, since forwardRef re-adds ref via `RefAttributes<T>`
to the external component type.
Side benefit: for the handful of non-forwardRef components (Link, Form,
FormItem, Descriptions), this removes `ref` from the prop type so consumers
can no longer pass a non-functional `ref` prop.
Zero external API change for forwardRef components — `<Button ref={...}/>`
still type-checks via `RefAttributes<HTMLButtonElement>`.
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.
Summary
React.PropsWithRef<JSX.IntrinsicElements['x']>relied on the globalJSXnamespace, which@types/react@19no longer augments. Under React 19 the type collapsed toany, silently droppingonClick,type,disabled,aria-*,children, etc. from every affected component.React.ComponentProps<'x'>/React.ComponentPropsWithoutRef<'x'>across ~60 type files.PropsWithRef/PropsWithoutRefare deprecated no-op aliases in React 19 anyway, so the rewrite is also a cleanup.Notes on the reported issue
The issue's diagnosis ("
HTMLAttributes<T>no longer includeschildren") is inaccurate —DOMAttributes<T>in@types/react@19still haschildren. The real cause is the missing globalJSXnamespace. The issue's suggested fix (addingchildrentoBaseProps) would have masked the most visible symptom while leaving every other HTML prop still broken.Reproduced against
@types/react@19.2.14+typescript@5.9.3in a scratch workspace: the original pattern fails withCannot find namespace 'JSX'andProperty 'onClick'/'type'/'disabled'/'children' does not exist; the new pattern type-checks cleanly.Test plan
tsc --noEmiterrors inpackages/react(10 pre-existing errors on master, unrelated)onClick,type,disabled,aria-*,children) all resolve<Button variant="solid" onClick={...} disabled>...</Button>without TS errors