Skip to content

Auto-import suggests deep nested paths over the top-level exports. #41667

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

Closed
just-boris opened this issue Nov 21, 2020 · 2 comments
Closed

Auto-import suggests deep nested paths over the top-level exports. #41667

just-boris opened this issue Nov 21, 2020 · 2 comments
Assignees
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@just-boris
Copy link

  • VSCode Version:1.51.1
  • OS Version: MacOS 10.15.7

Steps to Reproduce:

Given the following project structure

// node_modules/my-lib/internal/component.d.ts
export class Component {}

// node_modules/my-lib/index.js
export { Component } from './internal/component';

When I am trying to use "Component" class, the editor automatically suggests the import from 'my-lib/internal/component' path.

Screenshot 2020-11-21 at 14 09 46

This may lead to issues, where users inadvertently use private paths, which were not intended by package authors.

P.S. I found a relevant issue #35395, however that was about maintaining some sort of "exclude list" manually, whereas this report is about the editor automatically preferring top-level paths over the internal folders out of the box.

Does this issue occur when all extensions are disabled?: No suggestions at all when extensions are disabled.

@mjbvz mjbvz transferred this issue from microsoft/vscode Nov 24, 2020
@mjbvz mjbvz removed their assignment Nov 24, 2020
@andrewbranch
Copy link
Member

@just-boris can you provide an example repo that demonstrates this problem? Reason I ask is that I’ve seen this functionality work correctly for a long time, so it must be something specific to your packages/settings/??? that's causing the issue.

@andrewbranch andrewbranch added the Needs More Info The issue still hasn't been fully clarified label Nov 25, 2020
@andrewbranch andrewbranch self-assigned this Nov 25, 2020
@just-boris
Copy link
Author

Hello!

Seems like it was the issue on my side, I confused default and named exports.

When I fixed this, the editor gives no suggestions, however it starts suggesting the same import if one was already used in the project.

I think, this works as expected and I will close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

3 participants