Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With React 19 typings: Cannot find namespace 'JSX'. #1559

Open
Philipp91 opened this issue Dec 7, 2024 · 1 comment
Open

With React 19 typings: Cannot find namespace 'JSX'. #1559

Philipp91 opened this issue Dec 7, 2024 · 1 comment

Comments

@Philipp91
Copy link

I previously posted about this here, but I don't want to spam that thread.

node_modules/@dnd-kit/core/dist/components/Accessibility/Accessibility.d.ts:9:129 - error TS2503: Cannot find namespace 'JSX'.

9 export declare function Accessibility({ announcements, container, hiddenTextDescribedById, screenReaderInstructions, }: Props): JSX.Element | null;

We basically need s/JSX.Element/React.JSX.Element to fix this. There are two occurrences in this repo itself, for which I will send a PR. Though this requires updating to v18 typings first.

But most of the JSX.Element occurrences seem to come from the build process, which materializes types that were previously not spelled out explicitly.

@Philipp91
Copy link
Author

The dist/ directories aren't committed to this Git repository. But my current understanding is that they are part of the NPM package, so they're not built on the library user's machine, but on the library maintainer's machine when building the release.

When I clone the repo and run yarn install, I get the correct typings already:

$ yarn install
$ cat packages/core/dist/components/Accessibility/Accessibility.d.ts
...
export declare function Accessibility({ announcements, container, hiddenTextDescribedById, screenReaderInstructions, }: Props): React.JSX.Element | null;

Whereas in my main app's repo from NPM I got this installed:

export declare function Accessibility({ announcements, container, hiddenTextDescribedById, screenReaderInstructions, }: Props): JSX.Element | null;

and I see the same on https://www.npmjs.com/package/@dnd-kit/core/v/6.3.1?activeTab=code.

Given that the yarn.lock should fix all the versions, it's not clear to me why I get a different result than what's released.

@clauderic I assume it's GitHub Actions like this one that build the releases. Just as another data point, on your own machine, do you get React.JSX.Element or JSX.Element? Then we can compare how the environments differ to figure out how we can get the release environment to produce the new-style typings.

@Philipp91 Philipp91 changed the title With React 91 typings: Cannot find namespace 'JSX'. With React 19 typings: Cannot find namespace 'JSX'. Dec 7, 2024
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

No branches or pull requests

1 participant