Skip to content
153.7k

BlogGuides

Find TypeScript callers before a refactor

Find TypeScript callers before a refactor

Before you refactor a TypeScript function, list the callers that will break if the signature or the behavior changes, including the ones the diff will not show.

This walkthrough uses the Graphify CLI on a public checkout of honojs/hono at commit f6fbaf0 (11 November 2026). The same commands work in other TypeScript repositories. The language-agnostic version is code change blast radius.

How do I find every TypeScript caller before a refactor?

Build a code graph of the repository with graphify update ., then run graphify affected symbolName. The CLI walks backward from the symbol and lists callers, importers and re-exports with file and line.

bash
uv tool install --python 3.12 graphifyy
git clone https://github.com/honojs/hono.git
cd hono
git checkout f6fbaf0
graphify update .
graphify affected "HTTPException"

On this checkout the CLI read 538 files and finished in about 7 seconds. The graph had 4,066 nodes, 8,050 edges and 275 communities. Of those edges, 7,854 were EXTRACTED and 196 were INFERRED. The CLI's code pass wrote no AMBIGUOUS edges. Results vary by codebase.

HTTPException is a good refactor target because it is a small type with a wide blast radius. If you change its constructor, every middleware that throws it has to be reviewed. The start of the affected output on this checkout was:

text
graphify affected "HTTPException"
- buildRequestInitFromRequest() [calls] src/helper/proxy/index.ts:L70
- basicAuth() [calls] src/middleware/basic-auth/index.ts:L151
- bearerAuth() [calls] src/middleware/bearer-auth/index.ts:L149
- bodyLimit() [calls] src/middleware/body-limit/index.ts:L57
- csrf() [calls] src/middleware/csrf/index.ts:L146
- ipRestriction() [calls] src/middleware/ip-restriction/index.ts:L232
- jwk() [calls] src/middleware/jwk/jwk.ts:L87
- jwt() [calls] src/middleware/jwt/jwt.ts:L87
- cloneRawRequest() [calls] src/request.ts:L488
- createMountedRequest() [calls] src/utils/mount.ts:L69
- validator() [calls] src/validator/validator.ts:L103

The same command also lists the files that import or re-export HTTPException, including src/index.ts and the Cloudflare Pages adapter. That is the set you want open before you touch the constructor in src/http-exception.ts.

compose in src/compose.ts is a second, tighter example. graphify affected "compose" reported calls from .#dispatch() and .route() in src/hono-base.ts, and from every() in src/middleware/combine/index.ts. If you change how middleware is composed, those three functions are the first review targets.

Why is grep not enough to find TypeScript callers?

Grep finds the string, not the relationship. A call through a re-export, an alias or a wrapped helper can use a different name, or the same name in a different module, so the list is both noisy and incomplete.

TypeScript repositories also re-export heavily. A caller may import HTTPException from src/index.ts or from a middleware barrel, not from src/http-exception.ts. The graph keeps those re_exports edges, so the affected walk can reach them.

Does the TypeScript graph catch every caller?

No. Dynamic calls, partial extracts and names the CLI cannot resolve will not appear as EXTRACTED edges. Use the list as the set you must check, then still read the code around the change.

On this Hono checkout, a few TypeScript files only extracted in part, including src/context.ts, src/types.ts and src/helper/factory/index.ts. Counts from this graph are a lower bound. If graphify affected says a name is ambiguous, pick the node with path::symbol rather than assuming the first match is the one you are changing.

What should I do with the caller list before I merge?

Open each caller that sits outside the files you plan to edit, and either update it, add a test for it, or decide it is out of scope and say why in the pull request.

The same workflow in Python and Go is in how to generate a call graph for a Python project and Go interfaces: find every implementation and caller. After you edit, run graphify update . again, or install the hooks with graphify hook install so the graph rebuilds after commits, checkouts, merges and rewrites. The install guide covers setup, and the hosted app is at app.graphify.com.

Use Graphify in your agent

Add Graphify to ChatGPT, Claude, Cursor and more in one click.

Try Graphify now.

Try for free