Description
Suggestion
🔍 Search Terms
List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.
import autocomplete index.js completion javascript.preferences.importModuleSpecifier
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
When autocomleting imports using intellisense, the list of imports always seems to show only a single path, even when there are multiple paths available.
For instance, if you have file A.js
exporting a class, and B.js
importing and exporting that same class (using export * from "./Network/index.js";
for instance) the autocomplete list only shows either ./A.js
or ./B.js
based on your current location and your javascript.preferences.importModuleSpecifier
setting in vscode. This makes auto import useless if you prefer to import from a file that isn't listed.
📃 Motivating Example / 💻 Use Cases
According to https://dev.to/ndesmic/best-practice-tips-for-writing-your-js-modules-40o5
import * as foo from "foo.js"
is generally not a very disciplined way to go about things, you should import things by name so that it's very clear which things you actually intended to use.
For this reason, I'd like to import from the file that created the class as much as possible. However, since I am creating a library that I'd like to be able to build into a single file, exporting everything from a single index.js
is kind of inevitable.
But now every time I try to import a class, it keeps linking to the index.js
even though I want to link to the actual file.
If the autocomplete list would show all options, you wouldn't have to import files manually for cases where undesired path is chosen.