TypeScript: a local that shadows a project import is ignored from a nested arrow; the call links to the import
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- tooling
調査の方向性
Start in src/resolution/frameworks/react.ts around lines 391-401, where the nested skipValue arrow calls a local skipString but the edge lands on the import from object-literal.ts; the same shape repeats around lines 432-441. Compare that project-import path with the package-import path fixed in #2855, then reproduce with the use.ts sample to see the lexical shadow check only inspects the call node's own scope. Done means enclosing-function bindings win for project imports too, with tests covering both nested-arrow const and function shadows.
索引モデルが issue の本文から書いたものです。
説明
If a function declares a local that shadows a name the file imports from a project file, a call to that name from a nested arrow links to the import instead of the local. The same code importing from a package resolves correctly in every shape, thanks to #2855.
// lib.ts
export function skipString(j: number): number { return j + 1; }
// use.ts
import { skipString } from './lib';
export function scanA(s: string) {
const skipString = (j: number): number => j + 2;
return skipString(0); // line 4
}
export function scanB(s: string) {
function skipString(j: number): number { return j + 3; }
return skipString(0); // line 8
}
export function scanC(s: string) { return skipString(0); } // line 10
export function scanD(s: string) {
const skipString = (j: number): number => j + 2;
const skipValue = (j: number): number => skipString(j); // line 13
return skipValue(0);
}
export function scanE(s: string) {
function skipString(j: number): number { return j + 3; }
const skipValue = (j: number): number => skipString(j); // line 18
return skipValue(0);
}
| call | from './lib' (project) |
from 'some-pkg' (package) |
expected |
|---|---|---|---|
line 4 (scanA, own local) |
no edge | local at line 3 | local |
line 8 (scanB, own local function) |
no edge | local at line 7 | local |
line 10 (scanC, no shadow) |
lib.ts skipString |
none (package) | the import |
| line 13 (nested arrow, const shadow) | lib.ts skipString (resolvedBy: import) ✗ |
local at line 12 | local |
| line 18 (nested arrow, function shadow) | lib.ts skipString (resolvedBy: import) ✗ |
local at line 17 | local |
The two marked rows are wrong edges. The two "no edge" rows for the project import are missing edges rather than wrong ones. The import resolver appears to check for a shadow only in the calling node's own scope, not in the functions around it, and only the package-import path (#2855) prefers the local.
Reproduced on main at 31ec9082 (6162d872 since then only touches the watcher), with CODEGRAPH_KERNEL=0. Linux/WSL2, Node 22.23.2.
In this repo. src/resolution/frameworks/react.ts has the same shape. readObjectValue declares const skipString (lines 392–396), and the nested skipValue arrow calls it at line 401. That call links to skipString in object-literal.ts, which react.ts imports. The same shape occurs again at line 441, against a second local skipString declared at line 432. I found these by checking every TS calls edge against the TypeScript checker.
Expected. Apply the same lexical shadow check to a name imported from a project file as to one imported from a package: the innermost binding in scope at the call wins, including bindings in enclosing functions.
Related: #2855, #1715.
- 主要言語
- C
- スター
- 73.2k
- フォーク
- 4.7k
- 平均マージ
- 3時間 31分
- マージ済み PR(30日)
- 546
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 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 件 ·
メンテナーはふだん 1 日以内に返信
colbymchenry/codegraph の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Status: Opened Type: Bug
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
luainkernel/lunatik#2221 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
FriendsofECCE/ECCE#731 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
zephyrproject-rtos/zephyr#124160 ·
メンテナーはふだん 3 日以内に返信