You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Find all references without /index in the import path #66170
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?
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?
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.
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?
Great! There's some documentation on the jsconfighere. This has some information about language extensions in general - all built in language support is from extensions that are bundled from VSCode
Activity
vscodebot commentedon Jan 7, 2019
(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
[-]Find All References with index.js file[/-][+]Find all references without /index in the import path[/+]RMacfarlane commentedon Jan 7, 2019
From the gif, it looks like you have a class
Textinindex.jsthat 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?jabacchetta commentedon Jan 7, 2019
Yes, that's correct, class
Textis a default export React component inText/index.js, and is being imported many different times. Node, Webpack, etc. will automatically assume that you're importing from theindex.jsfile when the import path leads to a directory, so it isn't required to get a working app.However, in VSCode,
find all referencesonly finds the import with the/indexexplicitly in the path.As a comparison, WebStorm finds the references correctly without the
/index, so I assume this should at least be possible.RMacfarlane commentedon Jan 7, 2019
What does your
jsconfig.jsonlook like? Does setting the module like in #36699 resolve the issue?jabacchetta commentedon Jan 7, 2019
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?
RMacfarlane commentedon Jan 7, 2019
Great! There's some documentation on the
jsconfighere. This has some information about language extensions in general - all built in language support is from extensions that are bundled from VSCode