Skip to content

[BUG] TypeScript Error in React 17 Due to React.JSX Reference #1248

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

Open
lfersoy opened this issue Apr 10, 2025 · 2 comments
Open

[BUG] TypeScript Error in React 17 Due to React.JSX Reference #1248

lfersoy opened this issue Apr 10, 2025 · 2 comments
Labels

Comments

@lfersoy
Copy link

lfersoy commented Apr 10, 2025

Bug description
After upgrading to the latest version of react-tooltip, I encountered a TypeScript error in the library’s type definitions. The issue is caused by a reference to React.JSX in the TooltipWrapper declaration, which is not supported in React 17 projects using @types/react v17.
Upon investigation, I noticed that starting from react-tooltip@v5.20.0, the library updated its @types/react dev dependency from 18.0.28 to ^18.2.17. This change introduces compatibility issues for projects still using @types/react v17.
Could you please confirm if this dependency bump is strictly necessary? Upgrading @types/react in my current setup is not straightforward.

Environment

  • React version: 17.0.2
  • React DOM version: 17.0.2
  • React Tooltip version: 5.28.1
  • @types/react version: 17.x

To Reproduce

  1. Use a React 17 project with this tsconfig.json:
{
  "compilerOptions": {
    "target": "ESNext",
    "moduleResolution": "Node",
    "allowJs": false,
    "noEmit": true,
    "strict": true,
    "jsx": "react",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "module": "CommonJS",
    "noErrorTruncation": true,
    "types": [
      "node"
    ],
    "forceConsistentCasingInFileNames": true
  }
}
  1. Install react-tooltip@5.28.1.
  2. Run tsc.

Expected behavior
No errors to be reported. Typescript should build successfully

Actual Behavior
Error: node_modules/react-tooltip/dist/react-tooltip.d.ts:250:193 - error TS2694: Namespace 'React' has no exported member 'JSX'.

@lfersoy lfersoy added the Bug label Apr 10, 2025
@gabrieljablonski
Copy link
Member

I'm not sure how relevant it would be for us to provide this level of backwards compatibility, but we will keep it mind.

A relatively easy fix in your case would be to use something like patch-package to fix it "manually" (substitute the React.JSX references to use the old syntax) in that specific codebase.

Let us know if that works for you.

@lfersoy
Copy link
Author

lfersoy commented Apr 15, 2025

Hi @gabrieljablonski, thanks for the quick reply and suggestions!

Using patch-package isn’t a viable option in my specific case, as there are other projects consuming the components, and I’d need to ensure that those projects also install it for the patch to take effect consistently. While it technically works, it’s not practical in my setup.

At this point, I’m leaning toward reverting to an earlier version of the react-tooltip library—one that doesn’t include the @types/react changes.

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

No branches or pull requests

2 participants