Issue with React Import Syntax in VSCode: Getting 'import ... =' Error

19 Views Asked by At

I'm encountering a problem while trying to import React in my React project within VSCode. Usually, when I use IntelliSense to import React, it should import as import React from "react". However, it's importing as import React = require("react");, which leads to the following error message:

'import ... =' can only be used in TypeScript files

I've tried several approaches to resolve this issue, such as restarting VSCode, reinstalling VSCode extensions, and ensuring that my project setup is correct. However, the problem persists.

Could anyone please shed some light on why this issue might be occurring and how I can fix it? I'm relatively new to React development and would appreciate any guidance or insights. Thank you in advance!

0

There are 0 best solutions below