Webstorm automatic imports uses typescript build folder instead of src folder

I am currently using Webstorm to work on a larger project which is made up of smaller typescript projects.
The directory structure is something like this:

Clients
├- tsconfig.json
└- Packages
├- Core
| ├-┬ src
| | └- MyModule.ts
| └-┬ dist
| ├- MyModule.js
| └- MyModule.d.ts
└┬ Web
└-┬ src
└- WebComponent.tsx

Core/src contains my module where Core/dist contains my build.
When I auto-import a module on Web/src/WebComponent.tsx it auto-imports as @myApp/dist/MyModule But if I alt+enter on the import it says it's going to import from @myApp/src/MyModule

This is what my TSConfig paths look like (in the clients folder):

"baseUrl": "./",
"paths": {
"@myApp/core/src/*": ["./packages/core/src/*"],
}

I also tried this:

"baseUrl": "./",
"paths": {
"@myApp/core/*": ["./packages/core/*"],
}

I'm assuming webstorm uses tsconfig for finding imports but I'm still unsure. When I compile using tsc it seems to resolve the imports correctly (If I manually change the automatic dist imports too src)

Any ideas on how to fix this auto import?

3 comments
Comment actions Permalink

Could you share a sample project the issue can be repeated with?

0
Comment actions Permalink

Elena Pogorelova I'm having a similar issue. 

I have libraries where subpath typings for `<lib>/*` are in `<lib>/dist/types`, with paths mapped using `exports` and `typesVersions` in package.json.

Auto import (either "unambiguous on the fly" or "Add import statement" in the context menu) for `<lib>/x` imports from `<lib>/dist/types/x`, which is a typescript error. The explicit import option in the context menu says 'Add import from "<lib>/x"' as it should, and using this option works correctly. 

I think it should be pretty trivial to create a repro project exhibiting the behavior. If you still need that, how should I post it? Gist?

BTW -- I have "don't import implicitly from '**/dist/types/**' in my settings and the auto-import *still* uses the wrong path.

0
Comment actions Permalink

>If you still need that, how should I post it? Gist?

A link to Github repo, or a link to file server where the zipped project is uploaded to, or gist - whatever suits you best

0

Please sign in to leave a comment.