Files
MailUI4Agents/plugins/dsh-mail-bridge/lib/attachment-ids.d.ts
JianFeeeee 4b1946ccb4 fix(dsh): 补共用库类型声明 + 测试前强制构建 —— 堵住两个会静默通过的通道
# 1. 缺 .d.ts 导致构建失败(上一提交引入)

`lib/attachment-ids.js` 是上一提交新增的共用库,但没配 `.d.ts`。dsh 桥走
TypeScript 编译,于是:

    src/index.ts(65,40): error TS7016: Could not find a declaration file for
    module '../lib/attachment-ids.js'

pi 与 opencode 不做类型检查,所以只有 dsh 会在这里红 —— 很容易被当成偶发放过。
补上声明,类型刻意写成 `unknown`:这个函数的全部意义就是接收**不可靠的输入**,
用 `string[]` 收窄签名会让人误以为调用方本来就该给对形状。

# 2. 测试从 dist/ 导入,却不先构建 → 可以测到改动前的旧产物

dsh 的测试有两类导入:`../lib/*.js`(直连源码)与 `../dist/index.js`(编译产物)。
test 脚本原本是纯 `node --test`,**不先构建**。于是「改 src → npm test 全绿」
完全可能只验证了旧 dist —— 实测就踩到了:提交前那次 361 通过跑的是改动前的产物,
`lib` 本身有覆盖(attachment-ids.test.mjs 直连 lib),但**入口的接线没被测到**。

加 `pretest: tsc -p tsconfig.json`(npm 会在 test 前自动执行)。

反向验证:往 src 注入一个类型错误后 `npm test` **EXIT=2**(构建先失败),
而不是拿旧 dist 蒙过去;恢复后 361 通过 / 0 失败。
2026-09-12 11:36:03 +08:00

14 lines
823 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* `attachment-ids.js` 的类型声明。
*
* 为什么这个文件必须存在dsh 桥走 TypeScript 编译(`tsc -p tsconfig.json`
* 而 `lib/` 下每个共用模块都配了 `.d.ts`。缺了它,`import { normalizeAttachmentIDs }
* from '../lib/attachment-ids.js'` 会报 TS7016隐式 any**构建直接失败** ——
* pi 与 opencode 不做类型检查,所以只有 dsh 会在这里红,很容易被当成"偶发"放过。
*
* 参数类型刻意写成 `unknown`:这个函数的全部意义就是接收**不可靠的输入**
* 模型可能给数组、JSON 字符串、单个 id、或混着 null 的数组),
* 用 `string[]` 之类收窄签名会让人误以为调用方本来就该给对形状。
*/
export declare function normalizeAttachmentIDs(value: unknown): string[];