TypeScript: a local initialized from a library call takes the one-method guess (follow-up to #2589)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, react, typescript
- 領域
- devtools
調査の方向性
Reproduce the five functions from the issue in a TypeScript fixture and run the resolver with CODEGRAPH_KERNEL=0, then trace where a local initialized from an outside-project call is assigned the single same-named project method. Compare that path with the annotated-local handling from #2589/#2811 and the outside-type rule in #2169; the fix belongs there, not in variable-name heuristics. Done means a-d emit no instance-method edge while existing project-local cases still resolve, with coverage for package imports, node: namespaces and DOM-typed receivers.
索引モデルが issue の本文から書いたものです。
説明
Follow-up to #2589. A method call on an untyped local initialized from a library call still links to the project's only method with that name. #2811 fixed this for a class component's render() and lifecycle methods, but an ordinary class method is still guessed.
// app.ts
export class App { render(): void {} translate(x: number): void {} close(): void {} }
// use.ts
import { createRoot } from 'react-dom/client';
import * as net from 'net';
import { createServer } from 'net';
export function a(el: HTMLElement) { const root = createRoot(el); root.render(null); }
export function b() { const s = net.createServer(); s.close(); }
export function c() { const s = createServer(); s.close(); }
export function d(canvas: HTMLCanvasElement) { const ctx = canvas.getContext('2d')!; ctx.translate(1); }
export function e(canvas: HTMLCanvasElement) { canvas.getContext('2d')!.translate(1); }
| function | edge on main |
expected |
|---|---|---|
a |
App.render (instance-method) |
none |
b |
App.close |
none |
c |
App.close |
none |
d |
App.translate |
none |
e (chained, no local) |
none | none |
Renaming the locals doesn't change anything, so this isn't the variable-name guess in #2946. The chained form e already links nothing; only the assigned local takes the guess. In each case the local's value comes from something the project doesn't declare: a package import, a node: namespace, or a method on a DOM-typed parameter. That fits #2169's "an outside type is not a project type" rule, but the type is never written down, so the rule doesn't fire.
Reproduced on main at 31ec9082 (6162d872 since then only touches the watcher), with CODEGRAPH_KERNEL=0. Linux/WSL2, Node 22.23.2.
Scale (found by checking every TS calls edge against the TypeScript checker). On excalidraw (14bb42e), 63 instance-method edges land on project code where tsc says the method is a library one. For example, every context.translate(…) on a canvas.getContext("2d")! local, as in packages/element/src/renderElement.ts, links to App.translate in packages/excalidraw/components/App.viewport.ts. On this repo there are 58. For example, server.close() on net.createServer(…) in __tests__/cli-unlock.test.ts links to the close() of the viewer's server interface in src/ui-server/index.ts. The interface method gets callers it never has.
Possible direction (not verified). When the local's initializer is a call whose callee resolves outside the project (an import from a package or node:, or a member of a receiver already typed as an outside type), treat the local as outside-typed: the same "no guess" outcome as an annotated const r: Root = createRoot(el) in #2589. #2152 has PHP's version of this ("an untyped receiver keeps a unique method only when named for it").
Related: #2589, #2811, #2169, #2946.
- 主要言語
- C
- スター
- 73.2k
- フォーク
- 4.7k
- 平均マージ
- 3時間 13分
- マージ済み PR(30日)
- 579
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
colbymchenry/codegraph のほかの issue
-
mcp: a projectPath naming a file inside a project returns isError ("Path is not a directory")対応中かも @maxmilian が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
colbymchenry/codegraph#2982 ·
メンテナーはふだん 1 日以内に返信
-
mcp: a non-object tools/call arguments crashes the handler and is reported as an internal error to retry対応中かも @kjgggggg が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
colbymchenry/codegraph#2981 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
colbymchenry/codegraph#2974 ·
メンテナーはふだん 1 日以内に返信
-
search: FTS special characters are deleted, not separated, so leaf(entry) matches nothing対応中かも @kjgggggg が 1 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
colbymchenry/codegraph#2971 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
colbymchenry/codegraph#2959 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
colbymchenry/codegraph の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
InukaAsith/TwinDesk#84 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
CanadaHonk/porffor#426 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
FujiNetWIFI/fujinet-firmware#2221 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 77/100
raysan5/raylib.com#132 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100