Skip to content

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

Open
@lfersoy

Description

@lfersoy

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 [email protected], 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 [email protected].
  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'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions