'Could not find a declaration file for module 'react/jsx-runtime'

I am using material-ui in react with typescript template. All of my code is working fine but I am getting this error on multiple lines (not an error warning but with red line as my code renders)

Could not find a declaration file for module 'react/jsx-runtime'. 'C:/Users/dell/Desktop/Web current Projects/typescript/card/node_modules/react/jsx-runtime.js' implicitly has an 'any' type.
  If the 'react' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react`ts(7016)


Solution 1:[1]

When you have this error, it is usually because you installed a library and you didn't install the types of that library.

To fix this error, you need to install @types/library-name using your package manager (npm or yarn).

Solution 2:[2]

As per @NearHuscarl's comment, a quick fix is to create your own declaration module for react/jsx-runtime. You can do this by opening the react-app-env.d.ts file (created by default when you use create-react-app), found in your project's root directory. Then add the following script to it:

declare module "react/jsx-runtime" {
    export default any;
  }

The create-react-app team don't believe this is an issue for create-react-app to solve, and suggest it's a problem with typescript version 4. So alternatively you can downgrade your typescript version until the typescript team provide a fix in a later version.

Solution 3:[3]

use yarn for manage package.

run this command

yarn install

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Mora
Solution 2 JimmyTheCode
Solution 3 Md. Bappy Mia