Skip to content

Types incompatible with React 19 - missing children on component props #120

@flobo3

Description

@flobo3

Types incompatible with React 19 — missing children on component props

Version: @tiny-design/react@1.13.1
React: 19.x
TypeScript: 6.x

Problem

In React 19, HTMLAttributes<T> (and by extension JSX.IntrinsicElements) no longer implicitly includes children. This means all component props that extend React.PropsWithRef<JSX.IntrinsicElements['...']> now lose the children prop.

Affected components (17 interfaces)

Component File
Button button/types.d.ts
ButtonGroup button/types.d.ts
Flex flex/types.d.ts
Space space/types.d.ts
Link link/types.d.ts
Skeleton skeleton/types.d.ts
Layout layout/types.d.ts
Sidebar layout/types.d.ts
Row grid/types.d.ts
Grid grid/types.d.ts
GridItem grid/types.d.ts
Col grid/types.d.ts
AnchorLink anchor/types.d.ts
StrengthIndicator strength-indicator/types.d.ts
Paragraph typography/types.d.ts
Heading typography/types.d.ts
Text typography/types.d.ts

Error

TS2322: Type '{ children: Element; ... }' is not assignable to type 'IntrinsicAttributes & Omit<ButtonProps, "ref"> & RefAttributes<HTMLButtonElement>'.
  Property 'children' does not exist on type '...'

Reproduction

import { Button, Flex } from '@tiny-design/react';

// Both fail in React 19:
<Button variant="solid">Click me</Button>
<Flex vertical gap="md">...</Flex>

Suggested fix

Use React.PropsWithChildren or explicitly add children?: React.ReactNode to each interface. For example:

- interface ButtonProps extends BaseProps, React.PropsWithRef<JSX.IntrinsicElements['button']> {
+ interface ButtonProps extends BaseProps, React.PropsWithRef<JSX.IntrinsicElements['button']>, React.PropsWithChildren {

Or alternatively, at the BaseProps level:

  type BaseProps = {
    style?: CSSProperties;
    className?: string;
    prefixCls?: string;
+   children?: React.ReactNode;
  };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions