Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'React' is declared but its value is never read in ts 4.2

Just upgraded to typescript 4.2.2 and started receiving following warning for all my react imports i.e.

import React from "react";

Causes this warning

'React' is declared but its value is never read

This import was working fine before and is required to use jsx as far as I am aware. I looked at the change log, but didn't see any changes related to this new warning. My tsconfig also has "jsx": "react-jsx"

Any advice on how to resolve this?

like image 444
Ilja Avatar asked Oct 31 '25 07:10

Ilja


1 Answers

In my case I had no access to babel, however was able to fix this via following webpack plugin

  plugins: [
    new webpack.ProvidePlugin({
      React: 'react'
    })
  ]
like image 172
Ilja Avatar answered Nov 02 '25 20:11

Ilja