refactor(phase-10): complete type safety enhancement

- Add types/api-responses.ts with ApiResponse<T>, PaginatedResponse<T>
- Add types/errors.ts with comprehensive error type hierarchy
- Replace all any usage (53 → 0, 100% reduction)
- Add RawAPI response interfaces for type-safe mapping
- Update catch blocks to use unknown with type narrowing
- Add getState mock to chatStore tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iven
2026-03-15 19:52:52 +08:00
parent a6b1255dc0
commit 6a66ce159d
9 changed files with 1467 additions and 92 deletions

View File

@@ -545,4 +545,19 @@ ZCLAW 是基于 **OpenFang** (Rust Agent OS) 的 AI Agent 桌面客户端,核
* ✅ TypeScript 类型检查通过
* ✅ gatewayStore 测试通过 (17/17)
*下一步: Phase 10 类型安全强化*
*Phase 10 已完成 ✅ (2026-03-15)* - 类型安全强化
* API 响应类型:
* ✅ 创建 `types/api-responses.ts` - ApiResponse<T>, PaginatedResponse<T>, WebSocketMessage<T>
* ✅ 创建 `types/errors.ts` - 完整错误类型层级 (AppError, NetworkError, AuthError 等)
* any 类型消除:
*`gateway-client.ts` - 12 处 any 替换为 unknown 或具体类型
*`gatewayStore.ts` - 35 处 any 替换,添加 RawAPI 响应接口
*`chatStore.ts` - 1 处 any 替换为 unknown
*`RightPanel.tsx` - 1 处 any 替换为 PluginStatus
* 类型减少: 53 → 0 (100% 减少,超出 50% 目标)
* 代码质量:
* ✅ TypeScript 类型检查通过
* ✅ chatStore 测试通过 (11/11)
* ✅ gatewayStore 测试通过 (17/17)
*下一步: Phase 11 Store 重构*