find_references_by_tsmorph
Locates the definition and all project-wide references of a TypeScript symbol at a specified position, enabling precise impact analysis before refactoring.
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.
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. |