[api-extractor] Source map segment without a source crashes SourceMapper with "Target is a folder, not a file"
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
调研方向
从 apps/api-extractor/src/collector/SourceMapper.ts 开始,尤其关注 #getMappedSourceLocation,并追踪如何处理没有源的 source map 片段。issue 提供了一个最小 .d.ts.map 复现示例,并指出预期的回退方式:没有映射源时,使用原始声明位置。使用 API Extractor 7.59.4 运行复现;完成的标准是运行结束,并针对 foo 报告 ae-missing-release-tag。
由索引模型根据 Issue 内容生成。
描述
Summary
API Extractor crashes when a .d.ts.map contains a mapping segment that has only a generated column and no source. The source map spec allows these segments, and rolldown 1.2.14 now emits them in declaration maps (rolldown/rolldown#11170). We hit this upgrading rolldown in https://github.com/sanity-io/sdk/pull/1445.
Repro steps
- Create these files:
package.json
{"name":"ae-repro","version":"1.0.0","types":"dist/index.d.ts"}
src/index.ts
export const foo: string = "foo"
dist/index.d.ts
export declare const foo: string
dist/index.d.ts.map (the second segment, qB, has one field: a generated column with no source)
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":"AAAA,qB"}
api-extractor.json
{
"projectFolder": ".",
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts",
"apiReport": {"enabled": true, "reportFolder": "<projectFolder>/etc/"},
"docModel": {"enabled": false},
"dtsRollup": {"enabled": false},
"compiler": {"overrideTsconfig": {"compilerOptions": {"strict": true}}}
}
mkdir etc && npx @microsoft/[email protected] run --local
Expected result: The run completes and reports ae-missing-release-tag for foo. It does when the mappings are AAAA,qBAAqB.
Actual result:
ERROR: Target is a folder, not a file: undefined
Target is a folder, not a file: undefined
EISDIR: illegal operation on a directory, read
at Object.readFileSync (node:fs)
at FileSystem.readFile (@rushstack/node-core-library/src/FileSystem.ts:1066:12)
at SourceMapper.#getMappedSourceLocation (@microsoft/api-extractor/src/collector/SourceMapper.ts:130:56)
Details
SourceMapper.#getMappedSourceLocation takes the nearest mapping item and runs path.resolve(path.dirname(sourceFilePath), nearestMappingItem.source). For a source-less segment source is empty, so the path resolves to the .d.ts file's folder. FileSystem.exists returns true for it, and the read fails.
Treating a mapping item with no source as "no mapping" would fix it, so the original .d.ts location is used.
Standard questions
| Question | Answer |
|---|---|
@microsoft/api-extractor version? |
7.59.4 |
| Operating system? | Mac (also Linux in GitHub Actions) |
| API Extractor scenario? | reporting (.api.md) |
| Would you consider contributing a PR? | No |
| TypeScript compiler version? | 5.9.3 (bundled); also 6.0.3 in our project |
Node.js version (node -v)? |
24.12.0 (also 22 in CI) |
- 主要语言
- TypeScript
- 星标
- 6.5k
- 派生
- 710
- 平均合并
- 1 天 22 小时
- 30 天内合并 PR
- 37
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/rushstack 的其他 Issue
-
[rush-serve-plugin] The auto-picked port never reaches the port parameter: `_value` is ignored since ts-command-line uses `#value`可能已有人在做 @b84330808 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[rush] Upgrade the pnpm-sync-lib dependency to 0.3.5.可能已有人在做 @martinnaj 于 22 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
microsoft/rushstack#5971 · 2 条评论 ·
维护者通常 1 天内回复
查看 microsoft/rushstack 的全部 Issue
相似的 Issue
-
createAI: the ai peer range allows ai@6, which the provider cannot work with可能已有人在做 @akhil9tiet 今天认领。 未关闭bug
难度 1/5 1 小时以内 新手友好度 83/100
cloudflare/agents#2690 · 3 条评论 ·
维护者通常 1 天内回复
-
[fullsend] E2E: theme — global-header ignores app.branding.fullLogo (RHDHBUGS-3670)可能已有人在做 @fullsend-ai-coder 今天认领。 未关闭e2e-failure ready-to-code
难度 1/5 1 小时以内 新手友好度 78/100
redhat-developer/rhdh-plugin-export-overlays#4503 · 1 条评论 ·
维护者通常 1 天内回复
-
needs triage 📥
难度 1/5 1 小时以内 新手友好度 86/100
ethereum/ethereum-org-website#19601 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
cloudscape-design/components#5184 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
agilepathway/label-checker#805 ·
维护者通常 1 天内回复