Skip to content

Bug: Find All References in JS only shows references in open files #75341

Closed

Description

Issue Type: Bug

I've searched related issues:

I'm specifically talking about finding references of a symbol in JavaScript (ES modules) that is being exported.
Basically the opposite of Go To Definition (across files).

Reproduction Steps

  1. Export something from file A:
// file-a.js
function doSomething() {
  console.log('Hello There');
}

export default doSomething;
  1. Import that file in other files:
// file-b.js
import doSomething from './file-a'

doSomething();
  1. Right-click doSomething in file-a.js > Find All References

Expected

Should show file-b.js in the results.

Actual

file-b.js in not shown in the results (unless it is already opened in the editor!)

Notes

  • Same behavior if using named exports instead of default export

Updates based on comments

Adding jsconfig.json does solve this issue, based on this comment, BUT...
I really think it should work out of the box.

Migrating from WebStorm, this is an expected behavior, considering the fact that I've opened a folder in VS Code (meaning that's the project I want to work on).
I manage many different projects, do I now need to add jsconfig.json in each and every one of them?
This adds unnecessary friction.

Suggestion

I wish VS Code would just take a guess that I want all of the files in my project to be included for the Find All References feature.
Probably best to ignore node_modules and alike by default as well.

System Info

VS Code version: Code - Insiders 1.36.0-insider (f291714, 2019-06-12T05:18:48.847Z)
OS version: Darwin x64 18.6.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (8 x 2200)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.67GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none

Activity

  1. added
    javascript
    on Jun 12, 2019
  2. gjsjohnmurray commented on Jun 12, 2019

    @gjsjohnmurray
    Contributor

    Do you have a jsconfig.json file? See this comment on another issue.

  3. gjsjohnmurray commented on Jun 12, 2019

    @gjsjohnmurray
    Contributor
  4. alexilyaev commented on Jun 12, 2019

    @alexilyaev
    Author

    John Murray (@gjsjohnmurray) Indeed jsconfig.json made it work, I've updated the description under Updates based on comments.

    Basically, I think this should work out of the box.
    More Configuration === More Friction.
    Especially when migrating from WebStorm.

  5. mjbvz commented on Jun 12, 2019

    @mjbvz
    Contributor

    See the docs for more details on jsconfigs

  6. added
    *question
    on Jun 12, 2019
  7. alexilyaev commented on Jun 13, 2019

    @alexilyaev
    Author

    Matt Bierner (@mjbvz) I understand the desire to close issues, especially when there's a working solution.

    May I suggest, though, to reconsider this one.

    There is a way that VS Code could provide a better experience for developers.
    The minimum I'd expect is that VS Code would offer to add a jsconfig.json file when using a feature that heavily relies on that configuration.
    Otherwise, "Find All References" by definition won't find all references and will be considered broken (as it has been several times already and will continue in the future).

    But ideally, similar to how WebStorm works, VS Code could identify projects of certain natures and make a good guess by default, or at least offer a specific configuration based on the prediction (btw, WebStorm does that for many things like linters, file watchers, transpilers, etc.).

  8. Jake-Convictional commented on Jun 14, 2019

    @Jake-Convictional

    Agreeing with Alex Ilyaev (@alexilyaev) here, regardless of what the documentation says, this is a user experience bug. I just noticed this behaviour myself because it led to me introducing a bug into our production system, though I was sure that I had checked Find All References to confirm that the function I modified was only used in one place.

    If Find All References doesn't mean Find All References, then the name should be changed.

  9. gjsjohnmurray commented on Jun 14, 2019

    @gjsjohnmurray
    Contributor

    Matt Bierner (@mjbvz) maybe the extension implementing the ReferenceProvider in this case could at least show a warning message if there's no jsconfig.json and so it won't be able to do a comprehensive job of answering the user's Find All References request.

  10. elektronik2k5 commented on Jul 10, 2019

    @elektronik2k5

    I also agree with Alex Ilyaev (@alexilyaev) and Jake-Convictional. If the feature functions only as "Find references in open files" without a valid jsconfig.json in the project, then it should say so instead of misleading, surprising and disappointing users.

    One of the basic principles of UX is "don't surprise the user" and this is a clear and particularly bad violation of that rule.

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

Metadata

Metadata

Labels

*questionjavascript

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions