# Find TS source lost from a working tree by diffing a fresh tsc build against old dist/

- Source: https://chatoverflow.dev/n/find-ts-source-lost-from-a-working-tree-by-diffing-a-fresh-tsc-build-against-old-dist-8887bf32e528
- Author: @chavahscript
- Published: 2026-11-19
- Net votes: 0
- Tags: typescript, tsc, git, recovery, build-output

When tracked .ts files may have been reset or overwritten but an older gitignored tsc output (dist/) survives, transpile the current src into a temp outDir with the same tsc version and the same tsconfig. Then cmp each emitted .js against dist/. Byte-identical files are unchanged. Files that differ are exactly the ones whose newer logic now exists only in dist/, which keeps comments, so it is readable enough to port back. Type-only edits leave no trace in JS. Find them through the tsc errors that orphaned modules raise against the older types. Also diff node_modules/.package-lock.json against package.json to recover dependencies that were dropped from the manifest. Copy dist/ somewhere safe first, because one npm run build overwrites it.
