Skip to content

Connect TS barrel files and generic supertypes in the graph - #726

Merged
shhdwi merged 2 commits into
mainfrom
claude/pr553-do-or-kill-c86764
Nov 7, 2026
Merged

shhdwi merged 2 commits into
mainfrom
claude/pr553-do-or-kill-c86764

Conversation

@anirudhkumar-nanonets

@anirudhkumar-nanonets anirudhkumar-nanonets commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

The issue: in TypeScript, a barrel file (export { X } from "./x", export * from "./x") had no links out, so trail ask and trail callers stopped at it; implements Router<T> lost its link too.
Why: the extractor made imports links only from import statements, and took a supertype only when it was a bare identifier, so a generic one like Router<T> was dropped.
The fix: a re-export with a from now makes an imports link, and supertype names lose their type arguments (Router<T> → Router, ns.Base → Base), like the PHP and Swift paths.

Moves: graft_active, people who ran a trail query in the last 7 days (PostHog, Metabase DB 11, event = 'query'; card 17628 is the daily view). 10,338 on 2026-10-29. This makes TypeScript answers better; it won't visibly move the number.

This is the one part of the stale branch wip/jev-ask worth keeping; the rest of it, and draft #553, are left out (below).

What changes

src/graph/extract.ts, from wip/jev-ask (b1be58d), ported onto today's main:

  • Re-exports are import links. export { X } from "./x" and export * from "./x" now produce an imports link to ./x. A barrel file used to have no links out, so trail ask and trail callers stopped there. A plain export const x = 1 (no from) is untouched, and the walk still descends into it.
  • Generic supertypes keep their link. implements Router<T> puts a generic_type in the heritage clause; only a bare identifier was accepted, so the link was dropped. Type arguments are now erased (Router<T> → Router) and ns.Base reduces to Base, like the PHP and Swift paths.

Measured with main's extractor vs this one over each repo's tracked TS/JS files:

Repo Files Import links Barrel files with no link out extends + implements
Trail-Code 871 6,905 → 6,978 4 → 0 28 → 28
assign/frontend 2,764 13,053 → 13,224 16 → 0 18 → 19
trail-cloud 58 238 → 238 0 → 0 1 → 1

Calls, contains and references counts are identical before and after in all three, so nothing is lost.

Left out on purpose

Checks

  • test/graph-bindings.test.ts: 21/21 pass. 5 of the 7 new tests fail on main's extractor; the other 2 guard what must not change (plain exports, a generic base class that already worked).
  • Full npm test with a scratch HOME: 4,125 pass, 8 fail. The 8 are in graft-to-trail, hosts-trail, skills-* and upkeep-hooks tests; none import the graph code, they fail the same way with main's extract.ts swapped in, and the set changes run to run (machine load ~70 from parallel sessions).
  • trail check: no conflicts.
  • 2 Nov: merges cleanly with main at a44da3d (none of main's 4 new commits touch src/graph/); CI green on 2f11ea1; test/graph-bindings.test.ts 21/21 again.
  • 3 Nov: merges cleanly with main at b9c2e23. Find why trail sync crashes a laptop, and fix it #736 and Cut trail's peak memory on big repos #737 touch src/graph/ but not extract.ts; on the merged code the 42 graph and extract test files pass 413/413 and tsc is clean.

For the reviewer

🤖 Generated with Claude Code

@trailhq-graft

trailhq-graft Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🌱 graft blast radius

Nothing outside this diff depends on it. 1 area changed; no indexed dependents at depth 2.
Tests: no test reaches Type Hierarchy Extraction.
Tag: @shhdwi — Type Hierarchy Extraction · @Frankie-Xu — Type Hierarchy Extraction

Who knows this code — 2 people across 1 area
Area Who knows it
Type Hierarchy Extraction · changed @shhdwi — 5 commits, last yesterday · @Frankie-Xu — 5 commits, last 2mo ago

Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

Test signal per changed area — 1 ✗

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • ✗ Type Hierarchy Extraction — 0 of 4 reached · no test file reaches it
    • not reached: heritageEdges, tsSupertypeName, isImport, importSpecifier

⚠️ 1 changed file not in the graph (.trail/learnings/2026-10-29-ask-jev-loop-was-dropped-unmerged-anirudhkumar.md) — no parser claims the extension, or the index predates the file.

graft blast · origin/main...HEAD · depth 2 · 3 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

github-actions Bot added a commit that referenced this pull request Oct 29, 2026
yungSNAT referenced this pull request in yungSNAT/GrievousGreps Oct 31, 2026
Ported from upstream PR #726.

Co-authored-by: anirudhkumar-nanonets <[email protected]>
@shhdwi
shhdwi merged commit 0332716 into main Nov 7, 2026
10 of 11 checks passed
github-actions Bot added a commit that referenced this pull request Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants