Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritise import suggestions from tsconfig alias over external dependencies #31710

Open
jpike88 opened this issue May 26, 2019 · 4 comments
Open
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@jpike88
Copy link

jpike88 commented May 26, 2019

I get the following list when auto-suggest kicks in:

Screen Shot 2019-05-26 at 10 00 36 am

I always want to use the @shared alias I defined in my tsconfig file, and there appears to be no way to either omit the unwanted suggestions, or have my aliases be prioritised when auto-suggest/complete kicks in.

@mjbvz mjbvz transferred this issue from microsoft/vscode May 31, 2019
@mjbvz
Copy link
Contributor

mjbvz commented May 31, 2019

@RyanCavanaugh This issue shows quick fixes specifically but I believe same issue would also apply for auto import suggestions.

For quick fixes, VS Code will render them in the order TS Server returns them in.

For auto import suggestions, we could explore giving auto imports from local files a higher priority than those from node_modules.

@mjbvz mjbvz removed their assignment May 31, 2019
@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Jun 13, 2019
@jpike88
Copy link
Author

jpike88 commented Nov 19, 2020

Any more insight on this? It's a real pain and I'm considering whether I have change my User type to 'AppUser' or something clunky instead. I have a few classes with common names and it's so easy to accidentally import the wrong library. As the auto-suggestion dialog appears, I have to wait a full 1 second or so to confirm the import I want is coming from the correct module.

A lot of supporting imports are provided by large libraries like AWS and ag-grid, and I obviously can't exclude them from tsconfig.json... it's a really niggling problem, I've lost count of the errors I've made and it's the only thing stopping my coding from being a perfectly smooth experience.

ccing in more recent contibutors... @sandersn

Screen Shot 2020-11-19 at 2 51 00 PM

@cabal95
Copy link

cabal95 commented Sep 20, 2022

It's slightly out of scope from original request but I think related. It would be great to be able to specify which node modules take priority over others. For example, I am doing a lot of vue development and when I type watch, the default suggestion is always from fs instead of vue so I'm constantly adding the wrong import.

@ivosabev
Copy link

It seems to me that it should be a no-brainer that the priority order for imports and auto-imports should be:

  1. local files from the scope of the project
  2. aliased paths from tsconfig
  3. files from projects in the monorepo
  4. files from node_modules

And this should be regardless the importModuleSpecifier, the closer files should be first!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants