Skip to content

fix(typescript): resolve calls through destructured methods - #5612

Open
rvitaliy wants to merge 1 commit into
Graphify-Labs:v8from
rvitaliy:fix/typescript-destructured-typed-methods
Open

rvitaliy wants to merge 1 commit into
Graphify-Labs:v8from
rvitaliy:fix/typescript-destructured-typed-methods

Conversation

@rvitaliy

Copy link
Copy Markdown
Contributor

What does this PR do?

Resolve calls through a local immutable destructuring binding such as const { retire: finish } = owner; finish(). The receiver is an explicitly typed, required TypeScript parameter. The existing typed receiver resolver links the original call site to the declared member with INFERRED confidence.

Closes #5611. Related to #5586 and #5530.

Type of change

  • Bug fix

Verification & Invariants

  • Simple shorthand and renamed bindings keep the original call location and lexical caller, including inside a closure.
  • Resolution requires a unique, directly declared required callable on a non-generic, named interface or object alias. Optional members, accessors, ambiguous types, mutable bindings and unsupported patterns stay unresolved.
  • Extract and watch can reuse the required-member facts from the saved graph after a caller-only edit. AST cache schema 60 refreshes cached embedded TypeScript. Force a rebuild after upgrading to populate the new facts in an existing graph.
  • Verified the two missing calls in the real Booking Engine owner.

How was this tested?

  • Three regression cases fail on v8 and pass with the fix. The focused TypeScript, JS member and Astro suites passed on Python 3.14 (124 tests), and the typed receiver suite passed on Python 3.11 (21 tests).
  • Full Python 3.14 suite split across xdist (12,077 passed), the two worker-sensitive files without xdist (93 passed), and the serial group (282 passed).
  • ruff check ., git diff --check, and graphify update . passed. Pyright adds no diagnostics relative to v8.

Graphify-specific checklist

  • Verified lexical ownership, determinism, and incremental graph metadata.
  • Reviewed the diff for credentials and generated graph files.
  • Disclosed AI assistance in the commit trailer.

@rvitaliy
rvitaliy requested a review from safishamsi as a code owner November 28, 2026 23:28
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @rvitaliy. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 28, 2026

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify review View in Graphify

Review before merging · Merge confidence 3/5

1 bug · 9 possible issues to check · High impact

The change adds extraction and resolution support for calls through destructured TypeScript methods.

Bug  Destructured method calls are discarded because their declaration counts as a write · engine.py:4345

9 possible issues we couldn't confirm

They don't change the score.

What this review covered
  • We didn't review 1 file that isn't source code, such as docs, config, images, or generated or third-party code.
  • A changed file's diff was too long to show in full, so the review may not have seen every changed line in it.
  • Some findings could not be double-checked.
  • +1 more notes in Graphify.
  • 6 of 6 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 6855 functions depend on this change
  • 6 functions became more coupled. Largest: main() (137 callers), _extract_generic() (23 callers), _js_receiver_binding_scope() (4 callers).
  • 658 of 658 test files are affected by this change.
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed 9c18be7

Comment on lines +4343 to +4345
def _ts_destructuring_facts(root, source: bytes) -> tuple[set[str], dict[str, list[Node]]]:
"""Index names that need a lexical lookup and potential writes to bindings."""
names: set[str] = set()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug  Destructured method calls are discarded because their declaration counts as a write

A function that destructures a typed method into a const alias and calls it gets no call edge.

Exclude const destructuring declarations from write detection in _ts_destructuring_facts.

Evidence · checked against the code
  • Independent source review: Checked the downstream local-call handling: the call offset is retained as a local call and skipped by the later symbol-use walk. No route-level guard that preserves the typed-method resolution was found. The other member-call resolution path requires the destructured-method marker, which this failed binding lookup does not set.
Prompt to fix with AI
In graphify/extractors/engine.py, _ts_destructuring_facts (lines 4343-4345):
Problem: Destructured method calls are discarded because their declaration counts as a write
Fix it at the cause, and add a test that fails without the fix.

Graphify · Checked against the code · View in Graphify

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TypeScript calls through destructured methods of typed parameters are missing

1 participant