Closed
Description
Search Terms
- find references (shift f12)
- TypeScript server
Problem
If you run find all references
on an import path, tsserver will return a list of locations where this file is imported:
However it would also be useful to be able to run this command for a file without first having to find where it is imported. Some example use cases:
- Add a command to find references for the currently active file.
- Add a right click option in the explorer to find references to a selected file.
See microsoft/vscode#66150 for details on the VS Code side
Proposal
Add a new FileReferences
request to the tsserver protocol. This command would take a file path (and optional project name) and return a list of references:
interface FileReferencesRequest extends FileRequest {
// empty
}
interface FileReferencesResponseBody {
/**
* The file locations referencing the symbol.
*/
refs: readonly ReferencesResponseItem[];
/**
* The name of the symbol.
*/
symbolName: string;
}
interface FileReferencesResponse extends Response {
body?: FileReferencesResponseBody;
}
Running this command should return a list of locations where the given file is imported (this matches what running find all references on an import path does
)