FLVR
FLVR

Reputation: 59

Auto imports are always absolute from the src folder in a ReactJS project in WebStorm

Ever since the TS configuration, I have this issue where imports are always absolute from the source folder.

Here is an example:

I have a folder with components A.tsx and B.tsx. When I auto-import component B into component A, I expect the import to be as followed:

import B from './B';

The problem that I have is that WebStorm auto imports it as followed:

import B from 'app/components/subfolder/B';

Screenshots for my tsconfig.json and webpack configurations:

tsconfig.json

webpack configuration

I looked at this resource link and still was not able to change the auto-import back to relative. Configuring the Style of Imports in JavaScript and TypeScript

How can I change the auto-import back to its default behavior?

When the project is run with VS Code I don't have this issue as I can explicitly specify the Import Module Specifier to be the "shortest".

Upvotes: 1

Views: 2720

Answers (1)

NizTheDev Centrox
NizTheDev Centrox

Reputation: 23

In Visual Studio Code, menu File → Preferences → Settings → User Settings,

"typescript.preferences.importModuleSpecifier": "relative"

Upvotes: -2

Related Questions