How to make PyCharm JavaScript auto imports work correctly?

Up until recently PyCharm would automatically add node_modules import statements like:

import { useRef } from 'react';

now suddenly the only option it gives is this import

import { useRef } from 'react/cjs/react.production.min';

I've tried looking through the relevant preferences but have no idea what could be wrong. What settings have changed in recent updates that broke this?

4 comments
Comment actions Permalink

What IDE version do you use? Do you have @types/react installed in your project?

0
Comment actions Permalink

PyCharm 2019.2.6 (Professional Edition)
Build #PY-192.7142.79, built on February 7, 2020

I am not using `TypeScript` so I do not have `@types/react` installed. This used to work correctly regardless.

0
Comment actions Permalink

Typings are used in JavaScript projects as well. 

Is the issue reproducible for you in a new react project?

0
Comment actions Permalink

Adding `react/*` to Do not import exactly from in Preferences | Editor | Code Style | JavaScript fixed the problem. Wonder if that used to be the default but now it's not anymore.

0

Please sign in to leave a comment.