Skip to content

fix(typescript): extract methods from object type aliases - #5456

Closed
rvitaliy wants to merge 2 commits into
Graphify-Labs:v8from
rvitaliy:fix/typescript-object-alias-methods
Closed

rvitaliy wants to merge 2 commits into
Graphify-Labs:v8from
rvitaliy:fix/typescript-object-alias-methods

Conversation

@rvitaliy

@rvitaliy rvitaliy commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #5455.

type Port = { read(): number } and type Port = Readonly<{ read(): number }> now produce a method node and an ownership edge, with the signature's original source location. Typed receivers use the existing TypeScript resolver. The signatures stay out of bare-call, static-call, and module-symbol lookup.

Type of change

  • Bug fix

Verification & Invariants

  • Read CONTRIBUTING.md.
  • Reproduced the issue in .ts and .tsx and added regression tests.
  • Covered nested objects, unrelated or shadowed wrappers, calls through typed receivers, bare calls, and inheritance lookup.
  • Documented the supported shapes in ARCHITECTURE.md.

Readonly unwrapping is limited to an unqualified inline object argument when no local type binding shadows Readonly in the alias’s scope. The regression tests include unrelated generic parameters, private and exported names in reopened namespaces, calls through imported type aliases, and inheritance with or without the base declaration in the extracted files. The AST cache schema advances to 54 so an existing watch graph is rebuilt with the new declarations.

How was this tested?

uv sync --python 3.13 --frozen --all-extras
.venv/bin/python -m pytest tests/test_ts_object_alias_methods.py tests/test_ts_abstract_methods.py -q --tb=short
.venv/bin/python -m pytest tests/ -q --tb=short -n 8 -m 'not serial' --disable-warnings --durations=12
.venv/bin/python -m pytest tests/ -q --tb=short -m serial --disable-warnings
.venv/bin/ruff check .
.venv/bin/python -m tools.skillgen --check
git diff --cached --check

The issue's code-only CLI reproduction reports read() under all three types. The full suite passed on both Python 3.11.18 and 3.13.17 (11,880 parallel and 20 serial tests passed on each, with 134 skips and one expected failure). The Python 3.11 run used a separate environment from the same frozen lockfile. A Pyright comparison for the changed Python files found the same 226 existing diagnostics as upstream v8.

Graphify-specific checklist

  • AST extraction depends on source syntax.
  • Reviewed security implications and checked that the diff contains no keys or local graph data.
  • Disclosed AI authorship in the commit metadata.

Retain direct method signatures on named structural aliases and use typed receiver resolution without adding bare-name bindings.

Co-authored-by: Codex <[email protected]>
@rvitaliy
rvitaliy requested a review from safishamsi as a code owner November 24, 2026 14:33
@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.

@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

Looks safe to merge · Merge confidence 5/5

No issues reported · High impact

The change extracts direct method signatures from named TypeScript object aliases, including supported Readonly wrappers.

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.
  • Some lookups asked for files or lines that do not exist; the review was told and carried on.
  • One review pass used all of its turns for reading code, so it reported from what it had already read.
  • 5 of 5 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 6496 functions depend on this change
  • 3 functions became more coupled. extract() (1351 callers), extract_js() (104 callers), walk() (1 callers).
  • 621 of 621 test files are affected by this change.
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed 6186232 · 1 of 1 earlier findings resolved · 4 earlier findings not re-checked

Comment thread graphify/extractors/engine.py Resolved
Limit shadowing to the alias scope and cover imported receivers and heritage lookup.

Co-authored-by: Codex <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.121, landed via authorship-preserving cherry-pick so your commits keep your name. Thanks @rvitaliy!

@rvitaliy

Copy link
Copy Markdown
Contributor Author

Thanks for shipping #5456 in v0.9.121 and preserving the authorship, @safishamsi! I noticed one side effect of the cherry-pick workflow. GitHub didn’t close the linked issue when the fix landed, so I closed #5455 manually. #5464 is another example. Its fix shipped in the same release, and the issue is still open.

With 800+ open issues, some reports may already have shipped fixes. Could we include Fixes #<issue-number> in the commit that lands on v8 when cherry-picking a PR? That would keep the current workflow and let GitHub close the linked issue automatically. GitHub docs on closing keywords

@rvitaliy
rvitaliy deleted the fix/typescript-object-alias-methods branch November 26, 2026 23:20
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.

[Bug]: TypeScript object type aliases lose method signatures in the graph

2 participants