Repository navigation
Description
JS/TS: object-literal shorthand methods are never extracted, so factory/singleton-style modules yield only a file + const node
Version: graphifyy 0.9.30 (installed from the v8 checkout) · macOS 15.6 (darwin 24.6) · Python 3.14.6
Summary
The JavaScript/TypeScript extractor captures method_definition nodes inside a
class body, but never inside an object literal. Any codebase that defines
behaviour on object literals — the factory / singleton / module-object pattern
that is extremely common in Node services — therefore contributes only a file
node and a single const node to the graph, with zero methods and zero call
edges into them.
The failure is silent and, worse, flattering: the surviving const node still
accumulates imports edges from every module that imports it, so it shows up
near the top of graphify god-nodes with a high degree. That degree is entirely
"someone imported this module" — none of it is a call relationship. A user
reading god-nodes has no way to tell the difference.
Reproduction
mkdir -p jstest/src && cd jstest
cat > src/a.js <<'EOF'
export class RealClass {
classMethod() { return 1; }
}
export const topLevelObj = {
objMethod() { return 2; },
};
export const Factory = service({
name: "Factory",
methods: {
nestedMethod() { return 3; },
async nestedAsync() { return 4; },
},
});
export function plainFn() { return 5; }
EOF
graphify update .Nodes produced:
.classMethod() <-- class method: extracted
Factory <-- const: extracted (but no methods)
RealClass
a.js
plainFn()
topLevelObj <-- const: extracted (but no methods)
Missing: objMethod(), nestedMethod(), nestedAsync().
Note this is not about nesting depth or about the enclosing call expression:
topLevelObj.objMethod() sits in a plain top-level object literal assigned to an
exported const, and is still missed. The discriminator is purely
object literal vs class body.
Impact
On a real Node service codebase using this pattern, every service module
extracted to exactly 2 nodes regardless of size — including one 734-line module
with 18 methods. Measured across an 11-module service layer: ~1,700 LOC and 59
methods produced 22 nodes and 0 method nodes. Controllers and models in the same
repo, which use plain export function / export const declarations, extracted
normally at 5–8 nodes each.
The practical consequence is that explain / query / affected cannot answer
any question about the module's behaviour — "who calls X.someMethod" returns
nothing, with no indication that the symbol was never indexed in the first place.
Expected
Object-literal shorthand methods (and, ideally, function-valued pair entries
such as { handler: function () {} } and { handler: () => {} }) should be
extracted as function nodes owned by the enclosing const, the same way class
methods are.
Pointers
graphify/extract.py:738and:759already listmethod_definitionin
function_typesfor JS and TS respectively, so the node type is recognised —
it is the traversal that does not reach object-literal bodies.graphify/extractors/engine.py:4675has an
elif ct == "method_definition" and not top:branch, and:4733/:4738
similarly special-casemethod_definition; those paths appear to assume a
class-body parent.
In tree-sitter's JavaScript grammar the shorthand form inside an object literal
parses as method_definition under an object node, so this should be
reachable without a grammar change.
Secondary observation
Because the const node survives with only inbound imports edges, these modules
rank highly in god-nodes while being the least understood parts of the graph.
It may be worth either excluding pure-import degree from the god-nodes ranking
or annotating it, so a high-degree node with no outbound call edges is
distinguishable from a genuine architectural hub.
Activity
aryanbonigala commentedon Aug 3, 2026
I’m investigating this and plan to submit a focused fix with JS/TS regression tests. I’ll keep the initial scope limited to object-literal shorthand methods and avoid unrelated extractor changes.