Add import statement why am i getting absolute imports intead of relative

Hey everyone,

Is there a knob anywhere in WS where I can set to add imports relative to the place I am editing right now.

Namely if two files are in same directory and I want to import anything from one of them to the another I expect:

 

Expected behaviour after clicking alt + enter: 

import {a} from './a'; 

 

Currently I get

import {a} from 'catalog1/catalog2/a'; 

 

Setup:

WS, TypeScript

 

 

3 comments

Do you have path mappings in your tsconfig.json? When they are configured, WebStorm always uses absolute paths relative to specified "paths" value when generating import statements

0

Hi Elena,
Thank you for your answear. It helped me solved my problem somehow.

Please note that according to my observation not only tsconfig.json configures WS in a way you mentioned. Unfortunately, as it was in my case, tsconfig.anything.json takes precendence over tsconfig.json if they are both in root.

 

Best Reagrds

0

>Unfortunately, as it was in my case, tsconfig.anything.json takes precendence over tsconfig.json if they are both in root.

This is due to https://youtrack.jetbrains.com/issue/WEB-28091. See https://youtrack.jetbrains.com/issue/WEB-28091#focus=streamItem-27-2701519-0-0

 

0

Please sign in to leave a comment.