Skip to content

fix(react): restore intrinsic HTML props under React 19 types#121

Merged
wangdicoder merged 3 commits intomasterfrom
fix/react-19-types-compat
Apr 19, 2026
Merged

fix(react): restore intrinsic HTML props under React 19 types#121
wangdicoder merged 3 commits intomasterfrom
fix/react-19-types-compat

Conversation

@wangdicoder
Copy link
Copy Markdown
Owner

Summary

  • Fixes Types incompatible with React 19 - missing children on component props #120. 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 the pattern with React.ComponentProps<'x'> / React.ComponentPropsWithoutRef<'x'> across ~60 type files.
  • Works on React 18 and 19; PropsWithRef/PropsWithoutRef are 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 includes children") is inaccurate — DOMAttributes<T> in @types/react@19 still has children. The real cause is the missing global JSX namespace. The issue's suggested fix (adding children to BaseProps) 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.3 in a scratch workspace: the original pattern fails with Cannot find namespace 'JSX' and Property 'onClick'/'type'/'disabled'/'children' does not exist; the new pattern type-checks cleanly.

Test plan

  • All 798 unit tests pass
  • No new tsc --noEmit errors in packages/react (10 pre-existing errors on master, unrelated)
  • Smoke-tested the new pattern against React 19.2.14 + TS 5.9.3 — intrinsic props (onClick, type, disabled, aria-*, children) all resolve
  • Consumer on React 19 can pass <Button variant="solid" onClick={...} disabled>...</Button> without TS errors

`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>`.
@wangdicoder wangdicoder merged commit e928d14 into master Apr 19, 2026
1 check passed
@wangdicoder wangdicoder deleted the fix/react-19-types-compat branch April 19, 2026 00:34
@github-actions github-actions bot mentioned this pull request Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Types incompatible with React 19 - missing children on component props

1 participant