Skip to content

[Bug]: TS: a class field's type leaks to every same-named receiver in its file, so A.run binds this.repo.save() to RepoB.save #4294

Open

Description

@rohit-jsfreaky

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

Since 18682e8 (#4231, my PR) _ts_receiver_type_table types class fields, but it writes them into the per-file receiver table (name -> Type, first binding wins). That table is keyed by the bare name for the whole file, so a field's type reaches every receiver with that name in the file: with two classes in one file that each have a repo field of a different type, both classes' this.repo take one type, and A.run binds this.repo.save() to RepoB.save. It also types any local that happens to share a field's name.

The graphify-labs bot flagged this on #4231 and the PR had a second commit scoping fields per class, but only the first commit shipped in 0.9.81.

Steps to reproduce

mkdir demo && cd demo
printf 'export class RepoA { save(): void {} }\nexport class RepoB { save(): void {} }\n' > repos.ts
printf 'import { RepoA, RepoB } from "./repos";\nexport class A {\n  repo: RepoA;\n  run(): void { this.repo.save(); }\n}\nexport class B {\n  repo: RepoB;\n  run(): void { this.repo.save(); }\n}\n' > svc.ts
graphify update . --no-cluster
python -c "import json; g=json.load(open('graphify-out/graph.json')); n={x['id']:x['label'] for x in g['nodes']}; o={e['target']:n[e['source']] for e in g.get('links',g.get('edges',[])) if e['relation']=='method'}; [print(o.get(e['source']), n[e['source']], '->', o.get(e['target']), n[e['target']]) for e in g.get('links', g.get('edges', [])) if e['relation']=='calls']"

Error output or graph output

A .run() -> RepoB .save()     # wrong: A.repo is RepoA
B .run() -> RepoB .save()

Expected: `A .run() -> RepoA .save()` and `B .run() -> RepoB .save()`.

Graphify version

0.9.84 (1d1e03b)

Operating System

Windows

Python Version

3.12

Installation Method

built from source (git clone)

Additional Environment Details

No LLM keys; AST only. Clean checkout of v8 @ 1d1e03b (0.9.84) reproduces.

Additional context

Follow-up to #4231. PR right after this issue.

Activity

  1. added
    bug
    on Oct 10, 2026
  2. github-actions commented on Oct 10, 2026

    @github-actions

    Thanks for opening this issue, @rohit-jsfreaky. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions