Skip to content

fix(extract): emit inherits edge for JavaScript class extends - #1790

Open
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/js-class-extends-inherits
Open

fix(extract): emit inherits edge for JavaScript class extends#1790
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/js-class-extends-inherits

Conversation

@Synvoya

@Synvoya Synvoya commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Bug

Plain JavaScript class heritage was dropped: class Dog extends Animal {} emitted no inherits edge, while the equivalent TypeScript did.

Root cause

The JavaScript grammar stores extends and its identifier directly under class_heritage. TypeScript wraps the base in an extends_clause. The walker only handled the wrapped shape.

Fix

When a class_heritage node has no extends_clause or implements_clause, treat the heritage node itself as the JavaScript extends clause. The guard preserves the existing TypeScript path and prevents duplicate edges.

The implementation remains precision-first: direct same-file and imported identifiers resolve; runtime expressions such as extends mixin(Animal) are not converted into fabricated static inheritance. Qualified member expressions require namespace-aware resolution and remain outside this focused fix.

Validation

  • Added same-file JavaScript inheritance coverage.
  • Added imported JavaScript inheritance coverage.
  • Added a dynamic-base negative control.
  • Existing TypeScript interface, generic, imported and implements cases remain covered.
  • tests/test_ts_inheritance.py: 10 passed.
  • Ruff and git diff --check: passed.

@Synvoya
Synvoya force-pushed the fix/js-class-extends-inherits branch 3 times, most recently from 7e98bde to e8c3461 Compare July 27, 2026 02:41
@Synvoya

Synvoya commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up audit against current v8 found that JavaScript member-expression parents such as class Dog extends ns.Animal were still dropped. The branch now handles that AST shape and adds a regression test. Current validation: tests/test_ts_inheritance.py 9 passed; Ruff and git diff --check passed.

@Synvoya
Synvoya force-pushed the fix/js-class-extends-inherits branch from e8c3461 to da59be9 Compare July 27, 2026 04:15
@Synvoya

Synvoya commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Precision follow-up: I removed the member-expression tail normalization mentioned in my previous comment. Treating ns.Animal as bare Animal can falsely bind an unrelated same-file class without namespace-aware resolution. The final branch stays focused on direct JavaScript heritage identifiers, adds imported-class coverage and a runtime-expression negative control, and is squashed to one commit.

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.

1 participant