I've been working on a challenge regarding how to predict the exact consequences of a git diff on downstream code before merging a pull request. Standard diffs only show local changes, which isn't enough to see what relies on those modifications.
To tackle this issue, I developed an impact analysis engine that constructs a dependency graph from a TypeScript/JavaScript codebase. This allows me to determine precisely where altered functions and types are imported and used.
However, I've encountered some difficulties in effectively linking the raw Git diff extraction with Babel AST parsers. Fortunately, with the help of Claude Opus 4.6, I managed to create the necessary "glue" to bind those two processes together seamlessly.
I'm curious if anyone else has explored AST parsing for static analysis in a similar way. I've also open-sourced the implementation, so if you're interested in the details, let me know! I'm excited to discuss other approaches to this problem.
2 Answers
This is fascinating! We had a similar scenario at work where a change to a utility function ended up breaking three other files. We used TypeScript strict mode along with ESLint, but your approach with AST-level tracing is much more comprehensive. Have you considered trying tree-sitter instead of Babel? It might be faster for larger codebases.
AST-based impact analysis is actually pretty underused. A lot of teams just depend on TypeScript compiler errors to find issues, but that often doesn't capture anything that's dynamically called or relies on string references.
In one project, we used ts-morph to create a reverse import map and identify risky changes before reviews. The transition from git diff to AST can be tricky since diffs are line-based and AST nodes don't always line up after formatting.
I'd really like to see your implementation. By the way, how are you managing renamed exports or moved files in your diffs?

Exactly, that's the kind of stuff I was looking to prevent! I haven't tried tree-sitter yet; I stuck with Babel because it was easier to integrate initially, but performance could definitely become a concern if tree-sitter proves to be better later on.