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

@@ -404,17 +404,18 @@ export const useChatStore = create<ChatState>()(
m.id === assistantId ? { ...m, runId: result.runId } : m
),
}));
} catch (err: any) {
} catch (err: unknown) {
// Gateway not connected — show error in the assistant bubble
const errorMessage = err instanceof Error ? err.message : '无法连接 Gateway';
set((state) => ({
isStreaming: false,
messages: state.messages.map((m) =>
m.id === assistantId
? {
...m,
content: `⚠️ ${err.message || '无法连接 Gateway'}`,
content: `⚠️ ${errorMessage}`,
streaming: false,
error: err.message,
error: errorMessage,
}
: m
),