You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeScript: interface extends and same-file class extends not captured as inherits edges (walker only inspects class_heritage) #1095
After the TypeScript class-heritage extractor was added (class_heritage handling, present since ~v0.8.18), TS inheritance capture is still partial. Two cases produce noinherits/implements edge on v0.8.26:
interface A extends B (interface-to-interface heritage) -- never captured.
class X extends Y where Y is declared in the same file (only an imported superclass produces an edge).
class X extends ImportedClass and class X implements ImportedInterface work correctly.
Root cause (interface case)
_ts_walk_class_members in graphify/extract.py (the function that emits the heritage facts) only inspects the class_heritage child node:
In tree-sitter-typescript, only class_declaration / abstract_class_declaration produce a class_heritage node. An interface_declaration represents its heritage with a different node (extends_type_clause), which does not appear anywhere in extract.py.
So even though interface_declarationis dispatched into the walker (the dispatch set at ~line 6899 includes class_declaration, abstract_class_declaration, interface_declaration), the walker finds no class_heritage child and emits nothing. Verified by parsing interface Derived extends Base {} with tree-sitter-typescript: the node tree contains no class_heritage child (only class X extends Y produces one).
graphify update <dir> then inspect graphify-out/graph.json for links[].relation == "inherits".
Suggested fix
Handle the interface heritage node (extends_type_clause) in _ts_walk_class_members, mirroring the extends_clause path, emitting inherits for each entry.
For same-file class heritage: the superclass is not resolved unless it was already seen as a node; consider resolving same-file declarations so class X extends LocalClass also emits an edge.
Context
Inheritance support was added for C++/C#/Java when reported (#435 etc.); the TS interface/same-file gap appears to have no dedicated issue yet.
Fixed in 88a8e3b, shipping in the next release. Your root-cause analysis was exactly right on both cases @felipeathayde - confirmed the extends_type_clause node by parsing with the bundled grammar.
Case 1: interface extends
The walker only inspected class_heritage children, but interface heritage in tree-sitter-typescript is a separate extends_type_clause node (a direct child of interface_declaration, not wrapped in class_heritage). Added an extends_type_clause branch in _ts_walk_class_members that emits inherits facts. The existing _ts_heritage_clause_entries helper was directly reusable - the base entries under extends_type_clause are the same node types (type_identifier, generic_type, ...), so multiple extends (interface M extends A, B) and generic bases (extends Base<T>) work for free.
Case 2: same-file class/interface heritage
As you diagnosed, the heritage fact was emitted - the gap was in resolution. The use-fact resolver only consulted the import table (local_aliases_by_file, built solely from facts.imports), so a same-file base with no import alias was dropped while an imported one resolved. Added a same-file fallback against the file's own symbol_nodes (already keyed (path, label), so no new registration needed). Import resolution still takes precedence.
One refinement worth noting: I scoped the same-file fallback to inherits/implements only. The facts.uses list also carries same-file calls/type-uses, and those already resolve through the dedicated call-graph pass - widening the fallback to all relations produced duplicate edges. Heritage is the only relation that genuinely lacked a same-file path.
Tests
Added tests/test_ts_inheritance.py: interface single/multiple extends, generic base, same-file class extends, same-file implements, imported-interface extends, plus a regression guard that the originally-working imported-class case still emits its edge. Full suite green (1502 passed).
Activity
safishamsi commentedon May 31, 2026
Fixed in
88a8e3b, shipping in the next release. Your root-cause analysis was exactly right on both cases @felipeathayde - confirmed theextends_type_clausenode by parsing with the bundled grammar.Case 1: interface extends
The walker only inspected
class_heritagechildren, but interface heritage in tree-sitter-typescript is a separateextends_type_clausenode (a direct child ofinterface_declaration, not wrapped inclass_heritage). Added anextends_type_clausebranch in_ts_walk_class_membersthat emitsinheritsfacts. The existing_ts_heritage_clause_entrieshelper was directly reusable - the base entries underextends_type_clauseare the same node types (type_identifier,generic_type, ...), so multiple extends (interface M extends A, B) and generic bases (extends Base<T>) work for free.Case 2: same-file class/interface heritage
As you diagnosed, the heritage fact was emitted - the gap was in resolution. The use-fact resolver only consulted the import table (
local_aliases_by_file, built solely fromfacts.imports), so a same-file base with no import alias was dropped while an imported one resolved. Added a same-file fallback against the file's ownsymbol_nodes(already keyed(path, label), so no new registration needed). Import resolution still takes precedence.One refinement worth noting: I scoped the same-file fallback to
inherits/implementsonly. Thefacts.useslist also carries same-filecalls/type-uses, and those already resolve through the dedicated call-graph pass - widening the fallback to all relations produced duplicate edges. Heritage is the only relation that genuinely lacked a same-file path.Tests
Added
tests/test_ts_inheritance.py: interface single/multiple extends, generic base, same-file class extends, same-file implements, imported-interface extends, plus a regression guard that the originally-working imported-class case still emits its edge. Full suite green (1502 passed).Verified end-to-end via the CLI:
capture TS interface-extends and same-file class heritage (fixes Grap…
capture TS interface-extends and same-file class heritage (fixes Grap…