Skip to content

Conversation

wdcryer
Copy link
Contributor

@wdcryer wdcryer commented Oct 7, 2025

As of React 19, the JSX namespace is no longer global. It now uses React.JSX.
https://react.dev/blog/2024/04/25/react-19-upgrade-guide#the-jsx-namespace-in-typescript

As a result, usages of JSX.Element in this library throw type errors:

ERROR in ./node_modules/react-complex-tree/src/types.ts:367:14
TS2503: Cannot find namespace 'JSX'.
    365 |   C extends string = never
    366 | > extends TreeEnvironmentConfiguration<T, C> {
  > 367 |   children?: JSX.Element | (JSX.Element | null)[] | null;
        |              ^^^
    368 | }
    369 |
    370 | export interface UncontrolledTreeEnvironmentProps<

ERROR in ./node_modules/react-complex-tree/src/types.ts:367:29
TS2503: Cannot find namespace 'JSX'.
    365 |   C extends string = never
    366 | > extends TreeEnvironmentConfiguration<T, C> {
  > 367 |   children?: JSX.Element | (JSX.Element | null)[] | null;
        |                             ^^^
    368 | }
    369 |
    370 | export interface UncontrolledTreeEnvironmentProps<

ERROR in ./node_modules/react-complex-tree/src/types.ts:381:13
TS2503: Cannot find namespace 'JSX'.
    379 |   liveDescriptors?: LiveDescriptors;
    380 |   getItemTitle: (item: TreeItem<T>) => string;
  > 381 |   children: JSX.Element | (JSX.Element | null)[] | null;
        |             ^^^
    382 |   disableMultiselect?: boolean;
    383 | }
    384 |

ERROR in ./node_modules/react-complex-tree/src/types.ts:381:28
TS2503: Cannot find namespace 'JSX'.
    379 |   liveDescriptors?: LiveDescriptors;
    380 |   getItemTitle: (item: TreeItem<T>) => string;
  > 381 |   children: JSX.Element | (JSX.Element | null)[] | null;
        |                            ^^^
    382 |   disableMultiselect?: boolean;
    383 | }
    384 |

In @types/react, React.ReactElement appears to be equivalent to JSX.Element in v18 and and React.JSX.Element in v19. Using that type in place of JSX.Element should work in both React versions.
v18: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/v18/index.d.ts#L4363
v19: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L4077

Unfortunately I get errors when running yarn build so this should be checked before merging. Perhaps I should be using an older version of Yarn. I have the latest version and it seems to modify the lock file dramatically.

Solves #434

@lukasbach

@lukasbach
Copy link
Owner

Thanks for the contribution! yarn build seems to run fine in CI.

@lukasbach lukasbach merged commit 45a8700 into lukasbach:main Oct 7, 2025
6 checks passed
@wdcryer
Copy link
Contributor Author

wdcryer commented Oct 8, 2025

Thank you, @lukasbach!

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.

2 participants