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

[Bug]: Namespace 'React' has no exported member 'JSX'. #10824

Closed
su-kialo opened this issue Aug 28, 2023 · 4 comments
Closed

[Bug]: Namespace 'React' has no exported member 'JSX'. #10824

su-kialo opened this issue Aug 28, 2023 · 4 comments

Comments

@su-kialo
Copy link

What version of React Router are you using?

v6.15.0

Steps to Reproduce

react Version: v16.14.0
react-domVersion: v16.14.0

react-router-dom version v.6.15.0

  1. Run tsc with the following tsconfig
{
 // ...
    "compilerOptions": {
        "allowJs": true,
        "allowSyntheticDefaultImports": true,
        "noEmit": true,
        "experimentalDecorators": true,
        "importHelpers": true,
        "jsx": "preserve",
        "module": "esnext",
        "moduleResolution": "node",
        "sourceMap": true,
        "strict": true,
        "target": "es2015",
        "noErrorTruncation": false,
        "lib": ["dom", "es6", "dom.iterable", "scripthost", "es2016.array.include"],
        "noUnusedLocals": true,
        "resolveJsonModule": true
    },
 // ...
}

Expected Behavior

No errors to be reported.
Typescript should build successfully

Actual Behavior

The following error is reported by the Typescript compiler.

Error: node_modules/react-router-dom/dist/index.d.ts(36,107): error TS2694: Namespace 'React' has no exported member 'JSX'.

@su-kialo su-kialo added the bug label Aug 28, 2023
@brophdawg11
Copy link
Contributor

Could you provide a minimal reproduction of the issue?

@timdorr
Copy link
Member

timdorr commented Aug 28, 2023

Make sure your @types/react version is up to date. This is likely a version prior to 18.2.6, where React.JSX.Element was added and the global JSX.Element was deprecated.

@timdorr timdorr closed this as completed Aug 28, 2023
@su-kialo
Copy link
Author

Ok thanks.
For other reasons, we can't upgrade our version of React right now (we're working on it).

Is there documentation about the minimum supported React version for react-router?
If there is, I couldn't find it.

@timdorr
Copy link
Member

timdorr commented Aug 29, 2023

I believe the JSX namespace changes were backported to the older packages as well. 16.14.41 should be compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants