Skip to content

Commit 666b141

Browse files
committed
fix(react): restore intrinsic HTML props under React 19 types
`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.
1 parent e2e8b60 commit 666b141

63 files changed

Lines changed: 97 additions & 92 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tiny-design/react': patch
3+
---
4+
5+
Fix TypeScript compatibility with React 19. Component prop interfaces used the pattern `React.PropsWithRef<JSX.IntrinsicElements['x']>`, which relied on a globally-augmented `JSX` namespace that `@types/react@19` no longer provides. The resolved prop types collapsed to `any`, silently dropping every intrinsic HTML attribute (`onClick`, `type`, `disabled`, `aria-*`, `children`, etc.) for consumers on React 19. Replaced the pattern with `React.ComponentProps<'x'>` / `React.ComponentPropsWithoutRef<'x'>` across ~60 component type files. Works on React 18 and 19.

packages/react/src/alert/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type AlertType = 'success' | 'info' | 'warning' | 'error';
55

66
export interface AlertProps
77
extends BaseProps,
8-
Omit<React.PropsWithoutRef<JSX.IntrinsicElements['div']>, 'title'> {
8+
Omit<React.ComponentPropsWithoutRef<'div'>, 'title'> {
99
/** alert title */
1010
title?: string | ReactNode;
1111

packages/react/src/anchor/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface AnchorProps extends BaseProps {
1212
children?: React.ReactNode;
1313
}
1414

15-
export interface AnchorLinkProps extends BaseProps, React.PropsWithRef<JSX.IntrinsicElements['a']> {
15+
export interface AnchorLinkProps extends BaseProps, React.ComponentProps<'a'> {
1616
href: string;
1717
title: string;
1818
children?: React.ReactElement<AnchorLinkProps>[];

packages/react/src/aspect-ratio/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BaseProps } from '../_utils/props';
33

44
export interface AspectRatioProps
55
extends BaseProps,
6-
React.PropsWithoutRef<JSX.IntrinsicElements['div']> {
6+
React.ComponentPropsWithoutRef<'div'> {
77
/** the width of the content */
88
width?: number | string;
99

packages/react/src/avatar/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type AvatarPresence = 'online' | 'busy' | 'away' | 'offline';
66

77
export interface AvatarProps
88
extends BaseProps,
9-
React.PropsWithoutRef<JSX.IntrinsicElements['span']> {
9+
React.ComponentPropsWithoutRef<'span'> {
1010
/** use an icon */
1111
icon?: React.ReactNode;
1212

@@ -28,7 +28,7 @@ export interface AvatarProps
2828

2929
export interface AvatarGroupProps
3030
extends BaseProps,
31-
React.PropsWithoutRef<JSX.IntrinsicElements['span']> {
31+
React.ComponentPropsWithoutRef<'span'> {
3232
/** the distance between two avatars */
3333
gap: number | string;
3434
}

packages/react/src/badge/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BaseProps } from '../_utils/props';
33

44
export interface BadgeProps
55
extends BaseProps,
6-
React.PropsWithoutRef<JSX.IntrinsicElements['span']> {
6+
React.ComponentPropsWithoutRef<'span'> {
77
/** the number to show in badge */
88
count?: React.ReactNode;
99

packages/react/src/breadcrumb/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { BaseProps } from '../_utils/props';
33

44
export interface BreadcrumbProps
55
extends BaseProps,
6-
React.PropsWithoutRef<JSX.IntrinsicElements['nav']> {
6+
React.ComponentPropsWithoutRef<'nav'> {
77
separator?: React.ReactNode;
88
children: ReactElement<BreadcrumbItemProps> | ReactElement<BreadcrumbItemProps>[];
99
}
1010

1111
export interface BreadcrumbItemProps
1212
extends BaseProps,
13-
React.PropsWithoutRef<JSX.IntrinsicElements['li']> {
13+
React.ComponentPropsWithoutRef<'li'> {
1414
separator?: React.ReactNode;
1515
children?: React.ReactNode;
1616
}

packages/react/src/button/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type ButtonIconPosition = 'start' | 'end';
1212
export type ButtonGroupInheritMode = 'fill' | 'override' | 'none';
1313

1414
export interface ButtonProps
15-
extends BaseProps, React.PropsWithRef<JSX.IntrinsicElements['button']> {
15+
extends BaseProps, React.ComponentProps<'button'> {
1616
variant?: ButtonVariant;
1717
color?: ButtonColor;
1818
loading?: boolean;
@@ -27,7 +27,7 @@ export interface ButtonProps
2727
}
2828

2929
export interface ButtonGroupProps
30-
extends BaseProps, React.PropsWithRef<JSX.IntrinsicElements['div']> {
30+
extends BaseProps, React.ComponentProps<'div'> {
3131
variant?: ButtonVariant;
3232
color?: ButtonColor;
3333
size?: SizeType;

packages/react/src/calendar/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type SelectionMode = 'single' | 'range' | 'multiple';
77

88
export interface CalendarProps
99
extends BaseProps,
10-
Omit<React.PropsWithoutRef<JSX.IntrinsicElements['div']>, 'onChange' | 'onSelect' | 'defaultValue'> {
10+
Omit<React.ComponentPropsWithoutRef<'div'>, 'onChange' | 'onSelect' | 'defaultValue'> {
1111
/** Selected date (controlled, single mode) */
1212
defaultValue?: Date;
1313
/** Controlled selected date */

packages/react/src/card/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { BaseProps } from '../_utils/props';
33

44
export type CardVariant = 'outlined' | 'elevated' | 'filled';
55

6-
export interface CardContentProps extends React.PropsWithoutRef<JSX.IntrinsicElements['div']> {
6+
export interface CardContentProps extends React.ComponentPropsWithoutRef<'div'> {
77
prefixCls?: string;
88
children: ReactNode;
99
}
1010

1111
export interface CardProps
1212
extends BaseProps,
13-
Omit<React.PropsWithoutRef<JSX.IntrinsicElements['div']>, 'title'> {
13+
Omit<React.ComponentPropsWithoutRef<'div'>, 'title'> {
1414
title?: ReactNode;
1515
extra?: ReactNode;
1616
/** Card surface style */

0 commit comments

Comments
 (0)