fix(code-graph): resolve TypeScript method calls through typed class fields
What does this MR do and why?
Asking "who calls this method" returned nothing for one of the most common shapes in TypeScript: a method invoked on a typed class field. The field's declared type was never recorded, so the lookup had nowhere to go and the call site stayed invisible. Recording it lets the existing resolver finish the connection, and those callers now appear in the graph.
Related Issues
Relates to #1163 (closed)
This covers the TypeScript typed-field shape only. The Ruby and Go shapes in that issue are untouched, and so is the second TypeScript shape — see the question at the end of the agent context block.
Testing
New fixture suite typescript/class_field_method_calls.yaml, six cases covering cross-file fields, same-file fields, constructor parameter properties, and fields with no type annotation. Each fails on main and passes here.
mise test:fast (2510 passed), mise test:integration:codegraph (219 passed, the suite this fixture lives in), mise lint:code, and cargo fmt --check are green locally, rebased on current main.
Performance Analysis
Indexing gains one definition node per class field. This is the same cost already paid for Java, C#, PHP, Python, and Scala, whose analyzers emit a property definition per field today. No change to query paths, no new allocations in the resolver, no additional passes over the AST — the fields are read during the class-body walk that already runs.
I have left the box unticked because I have not measured this against an index of your size. The growth is bounded at one node per class field and it is the cost five other language analyzers already pay, so I would not expect a regression — but that is reasoning, not a measurement.
- This merge request does not introduce any performance regression. If a performance regression is expected, explain why.
Agent context — long-form analysis, file-by-file walkthroughs, profiler output, alternatives considered
Root cause
extract_class_members in crates/code-graph/src/v2/langs/custom/js/analyze/analyzer.rs skipped every class element that was not a method, so class fields never became definitions. extract_type_annotation also only matched AstKind::VariableDeclarator, so even a field that did become a definition would have carried no type.
The chain resolver in crates/code-graph/src/v2/linker/resolver.rs (resolve_chain) already handles this: on an ExpressionStep::Field it reads metadata.type_annotation off the member definition and uses it as the next scope. The mechanism was present and working; it was never handed the data.
For this._terminalProcess.start() the chain is [This, Field("_terminalProcess"), Call("start")]. Step 1 resolved to the enclosing class, step 2 found nothing, and the walk terminated before reaching start.
Change
JsDefKind::Property { class_fqn }added intypes.rs, mapped to the existingDefKind::Propertyinextract.rs. No ontology change — that graph kind is already emitted for computed properties and variables.extract_class_memberscollectsClassElement::PropertyDefinitionand TypeScript constructor parameter properties, reusing the raw-AST walk that already existed for abstract methods.extract_type_nameindataflow.rswidened from private topub(super)and reused for field annotations, so type-name parsing stays in one place.
Everything sits inside langs/custom/js/; the shared linker and pipeline are untouched, per crates/code-graph/AGENTS.md.
Constructor parameter properties turned out to matter more than expected: the call site named in the issue declares its field that way (ptyService.ts:764), so a class-body-only walk would have missed it. Type extraction handles a plain type reference and yields nothing for unions and generics, which fails closed — a missing edge rather than a wrong one.
Alternatives considered
- Side table of field types consulted at resolve time. Avoids new nodes, but the chain walker resolves members through graph definitions, so this needed changes in shared cross-language code and would have made JS the only language not describing its fields in the graph.
- Special-casing
this.x.y()inside the JS analyzer. Self-contained, but duplicates chain-walking logic that already exists generically and does not helpobj.field.method(). - Only emitting fields that carry a type annotation. Smaller node growth, but leaves TypeScript inconsistent with the other typed languages and makes a class's field list incomplete. Happy to switch to this if node volume is a concern.
Verification
Before, on a fixture mirroring ptyService.ts / terminalProcess.ts:
Calls edges between definitions: 0 rowsAfter:
| PtyService::startProcess | TerminalProcess::start | Calls |
| PersistentTerminalProcess::start | TerminalProcess::start | Calls |Fixture definition count went from 6 to 7 — one node for the new field.
A question about the second TypeScript call site
I tried to build a fixture for the interface case at ptyService.ts:432 and could not work it out, so I think I have misread something and would be grateful for a pointer.
The general point about interface dispatch does look real from here — I checked, and interface members are not currently extracted at all, so there is no ITerminalChildProcess::start node for a receiver of that type to resolve to. That seems worth a fix in its own right.
Where I got stuck is line 432 specifically. Reading the file at the pinned commit, pty there seems to come from this._ptys.get(id), and _ptys is declared Map<number, PersistentTerminalProcess> on line 100 — so I expected pty.start() to resolve to PersistentTerminalProcess::start at line 858, which is itself the method that calls TerminalProcess::start at line 860. I also could not find ITerminalChildProcess referenced anywhere in ptyService.ts itself; the only mention I found was the class declaration in terminalProcess.ts:85.
If that reading is right, line 860 would be the only direct call site, and the reproduction query in the issue would now return it. But I would rather check than assume — could you tell me what I'm missing?%{all_commits}