logoalt Hacker News

goda90today at 2:12 AM1 replyview on HN

A few years ago I set out to refactor some of my team's code that I wasn't particularly familiar with, but we wanted to modularize and re-use in more places. The primary file alone was 18k+ lines of Typescript that was a terrible mess of spaghetti. Most of it had been written in JavaScript but later converted haphazardly. I ended up writing myself a little app that used the Typescript compiler APIs to help me just explore all the many branches of the code and annotate how I would refactor different parts. It helped a bit, but I never got time to add some of the more intelligent features I wanted like finding every execution path between two points.


Replies

henryhaletoday at 3:57 AM

give depgraph a try - https://github.com/henryhale/depgraph - i'd like to learn about how i could improve it.