TypeScript: a local that shadows a project import is ignored from a nested arrow; the call links to the import
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 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 小时 15 分钟
- 30 天内合并 PR
- 576
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
colbymchenry/codegraph 的其他 Issue
-
mcp: a projectPath naming a file inside a project returns isError ("Path is not a directory")可能已有人在做 @maxmilian 于 1 天前认领。 未关闭
难度 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 于 2 天前认领。 未关闭
难度 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 于 2 天前认领。 未关闭
难度 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 小时 新手友好度 62/100
JustAResearcher/gpu-unlock-ada#124 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
-
inflate: total_in uses plain += on c_ulong (32-bit on Windows), panics in debug for streams > 4 GiB未关闭
难度 1/5 1 小时以内 新手友好度 85/100
trifectatechfoundation/zlib-rs#570 · 1 条评论 ·
-
vim.filetype.match() prefixes a URL buffer name with the cwd before passing it to filetype functions未关闭
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
COVESA/dlt-daemon#925 · 1 个 reaction ·