Reputation: 8096
I have a shared ts library that I use for other projects. Within this library are resources that are used by other resources with the same library. This library is structured into directories like components/*
, interfaces/*
, services/*
, etc. At the root of each of these directories is an index.ts
file that re-exports the resources within that directory. This is so the consuming project can import resources like:
import { FooService, BarService } from 'mylib/services';
Instead of:
import { FooService } from 'mylib/services/foo-service';
import { BarService } from 'mylib/services/bar-service';
The annoyance is that if I use an index.ts
file like this, WebStorm will suggest I import all library-local resources with it. I absolutely do not want to do that because it has led to unintended circular dependencies in the past. Within the lib itself, if components/foo-component.ts
wants to import FooService
, it should always import from ../services/foo-service.ts
and not ../services
.
But I can't get WebStorm to ignore these index files without marking them as Plain Text. Even if I exclude files named index.ts
in Preferences > Directories
, they will still appear as an option to include from.
How can I tell WebStorm to ignore index.ts
files when searching for imports? And to stop bugging me that my imports can be shortened.
Upvotes: 8
Views: 1573
Reputation: 93728
In Settings | Editor | Code Style | TypeScript | Imports, try disabling Use directory import when index.js is available (Node-style module resolution
Upvotes: -1