find_references_by_tsmorph
Locate a symbol's definition and all project-wide references using precise type-checker analysis.
Instructions
[ts-morph] Locate the definition AND every reference of a symbol at a given position, project-wide. Read-only.
When to use
Assessing the blast radius of a planned refactor before changing anything.
Answering "who calls this function?" / "where is this type used?" precisely.
Prefer this over
grepfor identifier lookups: grep matches unrelated same-name tokens (different scopes, comments, strings), while this tool uses the type checker to return only true references.
When NOT to use
You just want a free-text search (comments, strings, doc files) -> use
grep.You already plan to rename -> skip straight to
rename_symbol_by_tsmorph(it computes the same set internally and supportsdryRun).
Critical constraints
positionmust land on the symbol identifier itself (1-based line/column, as shown by editors). A position on whitespace or another token will fail to resolve.All paths (
tsconfigPath,targetFilePath) MUST be absolute.
Result
Returns the definition (file path, line, column, source line) when found, followed by a numbered list of references with the same fields.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"tsconfigPath": "<tsconfigPath>",
"targetFilePath": "<targetFilePath>",
"position": "<position>"
},
"name": "find_references_by_tsmorph"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tsconfigPath | Yes | Absolute path to the project's tsconfig.json file. | |
| targetFilePath | Yes | Absolute path to the file containing the symbol. | |
| position | Yes | The exact position of the symbol. |