Skip to content

fix(typescript): extract abstract method signatures - #3961

Closed
rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/ts-abstract-method-signatures
Closed

rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/ts-abstract-method-signatures

Conversation

@rajatnagda45

Copy link
Copy Markdown
Contributor

Problem

An abstract class's method was dropped from the graph, while the identical contract on an interface was kept:

interface Drawable { draw(): void; }      // draw -> node (method_signature)
abstract class Shape { abstract area(): number; }  // area -> dropped (abstract_method_signature)

So the base of an abstract class kept only its concrete methods, a polymorphic shape.area() had no declaration to resolve to, and the overridden contract had no node to carry it.

Implementation

An abstract method is the same kind of contract as an interface method: a subclass must implement it. interface methods (method_signature) were already a TS function type; abstract methods parse as abstract_method_signature, which was not.

Add abstract_method_signature to the TypeScript function types (inherited by the TSX config). Its name sits on the same name field as method_signature, so nothing else is needed.

Limitations

Abstract fields (public_field_definition with abstract) are left as-is, matching concrete fields, which are not nodes either. Scope is abstract methods only.

Verification

  • tests/test_ts_abstract_methods.py (new): the abstract method becomes a node; a concrete method and a free function calling it both resolve to it; parity with the interface method it mirrors. All fail on v8, pass with the fix.
  • uv run pytest tests/ — full suite green (6175 passed, 15 skipped). Existing TS suites (test_ts_inheritance, test_ts_namespace, test_typescript_enum_members, test_ts_decorators) unchanged.
  • uv run ruff check . clean; uv run pyright adds zero new errors.

An abstract class's `abstract area(): number;` parses as
`abstract_method_signature`, which was not a TypeScript function type, so the
abstract method was dropped. An interface's `method_signature` has long been a
function type, so `interface D { draw(): void }` put `draw` in the graph — but
the identical contract on an `abstract class` did not.

The result: the base of an abstract class kept only its concrete methods, a
polymorphic `shape.area()` had no declaration to resolve to, and the overridden
contract had no node to carry it.

An abstract method is the same kind of contract as an interface method: a
subclass must implement it. Add `abstract_method_signature` to the TS function
types (inherited by the TSX config). Its name sits on the same `name` field as
`method_signature`, so no other change is needed. Abstract fields
(`public_field_definition`) are left as-is, matching concrete fields which are
not nodes either.

Added tests/test_ts_abstract_methods.py: the abstract method becomes a node,
a call through the abstract type resolves to it, and it reaches parity with the
interface method it mirrors.
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

Thanks for the pull request, @rajatnagda45. 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.10 and 3.13, and that the change keeps extraction deterministic.

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.74 (live on PyPI as graphifyy==0.9.74). Landed on v8 as 699fab7 via an authorship-preserving cherry-pick, so your original commit authorship is kept intact. Thanks @rajatnagda45 for TypeScript abstract method signatures 🙏

Closing as shipped.

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.

2 participants