refactor(server): 清理全量 any 类型安全警告 (692 → 0)

- 全模块类型化:controller 的 req: any → AuthenticatedRequest/RequestUser,
  聚合查询 getRawMany 泛型标注、导入行/响应体定义具体 interface、
  catch (e: any) → unknown + 收窄、no-base-to-string 用 String() 显式转换
- 第三方无类型库边界(pdfkit/exceljs)文件级或单行 disable 并注明理由
- 顺带修复:get-business-context.tool 两个 require-await error、
  bills.controller 参数顺序隐患、main.ts compression 调用
- 运行时逻辑零改动;测试 142 套件 / 1065 用例全部通过
This commit is contained in:
2026-08-08 09:28:23 +08:00
parent 8b5fa98028
commit a644a8de42
63 changed files with 690 additions and 338 deletions

View File

@@ -166,6 +166,8 @@ function cellToText(cell: ExcelJS.Cell): string {
const value = getCellPrimitiveValue(cell);
if (value === null || value === undefined) return '';
if (value instanceof Date) return formatDate(value);
// 对象值(错误单元格/共享公式等)保留既有 String() 行为,不做类型收窄
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- 对象值保留既有 '[object Object]' 输出
return String(value).trim();
}
@@ -186,7 +188,10 @@ function parseDateText(cell: ExcelJS.Cell): string | undefined {
const value = getCellPrimitiveValue(cell);
if (value instanceof Date) return formatDate(value);
if (typeof value === 'number') return excelSerialToDate(value);
const text = value === null || value === undefined ? '' : String(value).trim();
if (value === null || value === undefined) return undefined;
// 对象值(错误单元格等)保留既有 String() 行为
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- 对象值保留既有 String() 语义
const text = String(value).trim();
if (!text) return undefined;
const normalized = text.replace(/[/.]/g, '-');
const match = normalized.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/u);