JS/TS: an `export default NAME` line inside a template literal is taken as the module's default export
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 64/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Start by reading statedDefaultExport in src/resolution/import-resolver.ts (lines 210-244) and the EXPORT_DEFAULT_HEAD scan loop that breaks on the first statement naming a node. Check what the extractor exposes for real export_statement positions so the loop can skip matches inside template or string literals rather than relying on a masker. Reproduce with the gen.ts/use.ts pair under CODEGRAPH_KERNEL=0, then confirm via the resolution tests that use resolves to Main and not App.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The default-export reader takes an export default NAME line inside a template literal as the module's default export when NAME is a node of the file. The real export default statement later in the file is then ignored.
// gen.ts
export function App() { return 1; }
export function Main() { return 2; }
export const template = `
export default App
`;
export default Main;
// use.ts
import X from './gen';
export function use() { return X(); }
edge on main |
expected | |
|---|---|---|
use → |
App (gen.ts:1, resolvedBy: import) ✗ |
Main (gen.ts:2) |
statedDefaultExport (import-resolver.ts#L210-L244) scans comment-stripped source but deliberately doesn't mask strings. Its docstring explains why: a masker thrown out of step by nested templates blanked real statements. It relies on "a statement must name a node of the file instead — one a template only writes as text names none — and of several statements, one that does wins". That fails when the template's text names a real node, as in code generators, scaffolding scripts and docs/test helpers that build module source in template strings. The loop takes the first statement that names a node and breaks, so the template wins whenever it comes first.
Reproduced on main at 72f398af with CODEGRAPH_KERNEL=0. Linux/WSL2, Node 22.23.2.
Possible direction (not verified). Skip an EXPORT_DEFAULT_HEAD match that sits inside a template or string literal, using the extractor's own export_statement positions (the AST already knows which export default is real) rather than a masker. Or, when several statements name nodes, prefer the one at module scope by AST.
Related: #2432 (introduced the stated-default reading), #2967.
- Ngôn ngữ chính
- C
- Star
- 73.2k
- Fork
- 4.7k
- Merge trung bình
- 3 giờ 31 phút
- Pull request đã merge (30 ngày)
- 546
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của colbymchenry/codegraph
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
colbymchenry/codegraph#3093 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows: npm-shim spawnSync missing windowsHide flashes a console window on every MCP server launchĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
colbymchenry/codegraph#3054 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
colbymchenry/codegraph#2974 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Security Vulnerabiliy] Vulnerable bundled `node.exe` detected (Node2Shell - CVE-2026-111497)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
colbymchenry/codegraph#2959 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
codegraph ui - does not workĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
colbymchenry/codegraph#1900 · 2 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của colbymchenry/codegraph
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:docs area:stdlib found-by:duet-audit kind:docs-drift
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
InauguralSystems/EigenScript#2251 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
flux-framework/flux-coral2#513 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ly05010419/MacNativeGames#1420 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Isaac workingĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
seedds/nxnative#763 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày