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

Suggestion: ability to find imports for module #22374

Open
OliverJAsh opened this issue Mar 7, 2018 · 8 comments
Open

Suggestion: ability to find imports for module #22374

OliverJAsh opened this issue Mar 7, 2018 · 8 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@OliverJAsh
Copy link
Contributor

Find references is a very useful feature, however sometimes I need to be able to find all imports of a given module:

  • regardless of what they're exporting
  • but the module does not have any exports

This is sometimes necessary when a module has side effects, and you want to see which files imported it.

This might also be useful for dynamic imports. In one project we have several dynamic imports (for code splitting) that never explicitly reference the module exports, so if I use find references on those module exports, I will not be shown the dynamic import. For example, here is a dynamic import:

image

When I activate find references on the exports of that module, I am not shown the import:

image

@mhegazy
Copy link
Contributor

mhegazy commented Mar 7, 2018

Find all refs on the module path should show you all imports to it:

image

@mhegazy
Copy link
Contributor

mhegazy commented Mar 7, 2018

Is that not sufficient for your scenarios?

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Mar 7, 2018
@OliverJAsh
Copy link
Contributor Author

I'm after the opposite—to find all imports for the currently focused module. E.g.:

// a.ts
// "find imports" used in this module will list the imports in `b.ts` and `c.ts`
export const foo = 'bar';
// b.ts
import('./a');
// c.ts
import './a';

@mhegazy
Copy link
Contributor

mhegazy commented Mar 7, 2018

I see.. I suppose we can expose this on the export keyword. though it is kinda weird.. possibly another command on the server..

@andy-ms, @amcasey and @DanielRosenwasser thoughts?

@mhegazy mhegazy added Suggestion An idea for TypeScript and removed Needs More Info The issue still hasn't been fully clarified labels Mar 7, 2018
@amcasey
Copy link
Member

amcasey commented Mar 7, 2018

@OliverJAsh to confirm, you're not looking for consumers of foo, you're looking for consumers of a.ts?

@OliverJAsh
Copy link
Contributor Author

OliverJAsh commented Mar 7, 2018 via email

@amcasey
Copy link
Member

amcasey commented Mar 7, 2018

@mhegazy I agree that it's not clear how we would trigger such a search. Personally, I would expect invoking Find All References on the export keyword to list references to that exported symbol.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 8, 2018

Personally, I would expect invoking Find All References on the export keyword to list references to that exported symbol.

yeah.. then a new command is needed, but it wounder if that will be discoverable.

@RyanCavanaugh RyanCavanaugh added the Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature label Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants