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

TypeScript Should Prioritize Aliased Imports #43849

Closed
dustinlacewell opened this issue Apr 27, 2021 · 3 comments
Closed

TypeScript Should Prioritize Aliased Imports #43849

dustinlacewell opened this issue Apr 27, 2021 · 3 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@dustinlacewell
Copy link

When you Alt-Enter on an unimported name, VSCode will offer to add the import if it can. In a monorepo situation, you'll likely have TypeScript aliases pointing to the thing you want to import from. VSCode lists these aliases, which is great, but it also lists the arbitrarily long possible relative import paths.

I know this is a small request, but VSCode should prioritize the shortest import path / the aliased path with regards to sorting the items in the context menu. That way the aliased import can be added by hitting enter at that context menu. It's a small quality-of-life issue that I run into hundreds of times a day it feels like.

Thanks so much for considering this request.

@mjbvz mjbvz transferred this issue from microsoft/vscode Apr 27, 2021
@mjbvz mjbvz removed their assignment Apr 27, 2021
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Apr 27, 2021
@RyanCavanaugh
Copy link
Member

I thought this was already the case, or was at least configurable

@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.4.0 milestone Apr 27, 2021
@andrewbranch
Copy link
Member

This should already be the behavior, definitely in 4.3 if not earlier. #42614 ensured that even same-named aliases of different origin symbols are sorted by number of directory separators. @dustinlacewell can you please use typescript@next in your workspace and/or use the JS/TS nightly extension and then share an example of the issue?

@dustinlacewell
Copy link
Author

"typescript.preferences.importModuleSpecifier": "non-relative"

did the trick, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

4 participants