Skip to content

Find all references without /index in the import path #66170

Closed

Description

I'm running into an issue where Find All References does not work if the import path does not include the /index. Is this expected? Is there a workaround available, or a fix on the way?

references

Activity

  1. vscodebot commented on Jan 7, 2019

    @vscodebot

    (Experimental duplicate detection)
    Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

  2. added
    editor-find
    on Jan 7, 2019
  3. changed the title [-]Find All References with index.js file[/-] [+]Find all references without /index in the import path[/+] on Jan 7, 2019
  4. RMacfarlane commented on Jan 7, 2019

    @RMacfarlane

    From the gif, it looks like you have a class Text in index.js that you're importing somewhere else. I would expect you to need to specify the complete absolute or relative path to the file to be able to import it - is there anything special about your project set up?

  5. added
    info-needed
    on Jan 7, 2019
  6. jabacchetta commented on Jan 7, 2019

    @jabacchetta
    Author

    Yes, that's correct, class Text is a default export React component in Text/index.js, and is being imported many different times. Node, Webpack, etc. will automatically assume that you're importing from the index.js file when the import path leads to a directory, so it isn't required to get a working app.

    However, in VSCode, find all references only finds the import with the /index explicitly in the path.

    As a comparison, WebStorm finds the references correctly without the /index, so I assume this should at least be possible.

  7. RMacfarlane commented on Jan 7, 2019

    @RMacfarlane

    What does your jsconfig.json look like? Does setting the module like in #36699 resolve the issue?

  8. jabacchetta commented on Jan 7, 2019

    @jabacchetta
    Author

    Yes, that did it, thanks Rachel Macfarlane (@RMacfarlane) !

    Do you have any suggestions on where to read up on the specifics of why these options are required, to get a better understanding of how VSCode works behind the scenes?

    In other words, I don't understand why that feature just wouldn't be baked in by default? Then again, maybe it's to keep strict error checks on so that the lines aren't blurred across specs?

  9. RMacfarlane commented on Jan 7, 2019

    @RMacfarlane

    Great! There's some documentation on the jsconfig here. This has some information about language extensions in general - all built in language support is from extensions that are bundled from VSCode

  10. locked and limited conversation to collaborators on Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    editor-findinfo-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions