Automatic Import Problem
I have a problem with automatic imports.
If i do auto imports the problem is instead of adding an import like:
import {Class} from "B"
Webstorm adds an import like:
import {Class} from "B/types/core/B"
I allways need to remove the /types/core/B manually which is time consuming and prone to error.
I have 2 Modules.Module A has module B linked via npm link.
Package JSON Entries of B:
"main": "dist/lib/src/index.js",
"module": "dist/lib/src/index.js",
"typings": "dist/types/src/index.d.ts",
dist/lib/src/index.js is a barrels file which contains this:
export * from "./core/B"
dist/types/src/index.dts looks quite the same:
export * from "./core/B"
Any Ideas?
Please sign in to leave a comment.
Please can you share a sample project I can use to recreate the issue?
May be related to https://youtrack.jetbrains.com/issue/WEB-30212, but I'm not sure what your project looks like, and "B/types/core/B" doesn't look like relative path
BTW, what WebStorm version do you work with?
Here is the Example i am using Webstorm 2018.1
https://github.com/Gr33nbl00d/webstorm-example-imports
To reproduce:
.\moduleb\npm run build
on modulea link moduleb with
npm link ..\moduleb
Now if you open the A.ts there is missing import of B when hitting ALT-ENTER --> Add Import Statements i get:
import {B} from "moduleb/dist/types/src/core/B";Thanks... When I open module-a folder as a project via File | Open, open A.ts and hit Alt+Enter to import B, I get
What IDE version do you work with? What do your Typescript import preferences (Settings | Editor | Code Style | TypeScript | Imports) look like?
Really ok than it might just be some idea/webstorm misconfiguration
I am using Typescript 2.7.2
Sorry forgot the webstorm version:
WebStorm 2018.1
Build #WS-181.4203.535, built on March 22, 2018
May be https://youtrack.jetbrains.com/issue/WEB-32081 then...
Please try upgrading WebStorm - does the issue persist?
Wow thank you so much it is FIXED! YEAHHH No more import corrections:)
I was quite sure this was a configuration problem from my projects not a webstorm problem thats why i didnt try to update :)
What did you do to solve it?