[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 重現範例,並指出預期的 fallback:沒有對應來源時,使用原始宣告位置。使用 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 天 23 小時
- 30 天內合併 PR
- 36
環境準備
在瀏覽器裡用你自己的 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/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 於 21 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
microsoft/rushstack#5971 · 2 則留言 ·
維護者通常 1 天內回覆
查看 microsoft/rushstack 的全部 Issue
相似的 Issue
-
agent/scanner help wanted hive/claimed-by-scanner kind/bug stage/020-claimed
難度 2/5 1-3 小時 新手友好度 90/100
hivecommons/rationguard#315 ·
維護者通常 1 天內回覆
-
agent-ready area: ui-sdk priority: p3 type: chore
難度 2/5 1-3 小時 新手友好度 76/100
schlessera/brain-kit#2534 ·
維護者通常 1 天內回覆
-
bug lane:gh-5
難度 2/5 1-3 小時 新手友好度 72/100
LLM-4-People/bridlewise-testing#122 ·
維護者通常 1 天內回覆
-
bug priority: P2
難度 1/5 1 小時以內 新手友好度 78/100
維護者通常 1 天內回覆
-
enhancement priority:low ready-for-dev
難度 2/5 1-3 小時 新手友好度 67/100
維護者通常 1 天內回覆