Search code examples
reactjswebpackwebstormtypescript-declarations

Jsx is used without importing react


I am getting the

Jsx is used without importing react

Notification by WebStorm even tho I made react library global via:

My webpack.config.js

        plugins: [
            new webpack.ProvidePlugin({
                React: "react"
            })
        ]

My declarations.d.ts

import _React from "react";
declare global {
    const React: typeof _React;
}

It is no error and the code runs fine, but I do not like such an unnecessary notification. How do I tell WebStorm that I did import react globally?


Solution

  • Just turn the inspection off in Settings | Editor | Inspections | JavaScript and TypeScript | Imports and dependencies, Missing React import with JSX