TypeScript: this.m() links to an imported function m instead of the class's own m
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- devtools
调研方向
Start from the import-binding path that answers a call edge, since the issue notes the this. receiver is lost before the bare refName reaches it; trace how this.groupDefinitions(...) at src/mcp/tools.ts line 3250 resolves into src/graph/symbol-lookup.ts. Compare with the same-class member ranking mentioned in 25776014, and inspect src/graph/named-symbol-flow.ts for the findAllSymbols case. Done means this.m() and super.m() edges point at the class member, not the file import; reproduce with CODEGRAPH_KERNEL=0 and check the cited repo edges.
由索引模型根据 Issue 内容生成。
描述
this.m() inside a class links to a function m that the file imports, not to the class's own m. This is the common case of a class wrapping a helper of the same name.
// lib.ts
export function findAll(q: string): string[] { return [q]; }
export const getFactor = (w: number): number => w;
// tools.ts
import { findAll, getFactor } from './lib';
export class Tools {
run(q: string) { return this.findAll(q); } // line 3
private findAll(q: string): string[] { return findAll(q).concat('own'); } // line 4
size(w: number) { return this.getFactor(w); } // line 5
private getFactor = (w: number): number => getFactor(w) * 2; // line 6
}
| call | edge on main |
expected |
|---|---|---|
line 3 this.findAll(q) |
lib.ts findAll (resolvedBy: import) ✗ |
Tools.findAll (line 4) |
line 4 findAll(q) |
lib.ts findAll ✓ |
same |
line 5 this.getFactor(w) |
lib.ts getFactor (resolvedBy: import) ✗ |
Tools.getFactor (line 6) |
line 6 getFactor(w) |
lib.ts getFactor ✓ |
same |
The class's own findAll and getFactor get no callers from run/size, and the import gets callers that never call it directly. The edge's refName is the bare name (findAll), so the this. receiver is already lost by the time the import binding answers.
Reproduced on main at 25776014 with CODEGRAPH_KERNEL=0. Linux/WSL2, Node 22.23.2. 25776014 ("a call on the caller's own class reaches that class's member") doesn't change this: that path ranks same-named methods, and here the import answers first.
In this repo. ToolHandler in src/mcp/tools.ts imports groupDefinitions from ../graph/symbol-lookup and also has a private groupDefinitions(...) (line 3220). this.groupDefinitions(allMatches.nodes, fileFilter) at line 3250 links to src/graph/symbol-lookup.ts. this.findAllSymbols(cg, symbol) at lines 3245 and 3328 does the same with src/graph/named-symbol-flow.ts, ignoring the class's own findAllSymbols (line 8675). I counted 7 such edges in the index of this repo, and 1 in excalidraw (this.getFormFactor(…) in App.tsx → packages/common/src/editorInterface.ts, ignoring App's private getFormFactor = …). Found by checking every TS calls edge against the TypeScript checker.
Expected. A call with a this. (or super.) receiver should never resolve through the file's import bindings. It names a member, not a binding in scope.
Related: 25776014 / #1952 (own-class members for this. calls), #2953 (x.m() resolved through the import of x).
- 主要语言
- C
- 星标
- 73.2k
- 派生
- 4.7k
- 平均合并
- 3 小时 31 分钟
- 30 天内合并 PR
- 546
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
colbymchenry/codegraph 的其他 Issue
-
A `../` entry in package.json `workspaces` makes a folder outside the project count as a workspace package, and a call gets linked to the wrong function可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
colbymchenry/codegraph#3093 ·
维护者通常 1 天内回复
-
Windows: npm-shim spawnSync missing windowsHide flashes a console window on every MCP server launch未关闭
难度 2/5 1-3 小时 新手友好度 86/100
colbymchenry/codegraph#3054 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
colbymchenry/codegraph#2974 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
colbymchenry/codegraph#2959 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
colbymchenry/codegraph#1900 · 2 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
查看 colbymchenry/codegraph 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 1/5 1 小时以内 新手友好度 80/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
eunomia-bpf/bpfix#7 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
python-pillow/Pillow#10370 · 1 条评论 ·
维护者通常 1 天内回复