From 986136171e5df8f07e694a29f8bcfbb9c6720925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Fri, 2 Oct 2026 18:57:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E5=9B=9E=E5=BD=92=E6=B5=8B=E8=AF=95=E7=9A=84=20invoke=20?= =?UTF-8?q?=E6=9B=BF=E8=BA=AB=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - vi.fn 返回固定签名,装不进 window.__TAURI__.core.invoke 的泛型签名,显式转成 TauriInvoke - tsc 不再报 TS2322;用例行为与断言不变 Co-authored-by: Junie --- .../chat/controller/useDirectProjectChatController.test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/ai-game-creator-shell/src/view/project-development/chat/controller/useDirectProjectChatController.test.tsx b/apps/ai-game-creator-shell/src/view/project-development/chat/controller/useDirectProjectChatController.test.tsx index 1b9999c58..8e41a0c5c 100644 --- a/apps/ai-game-creator-shell/src/view/project-development/chat/controller/useDirectProjectChatController.test.tsx +++ b/apps/ai-game-creator-shell/src/view/project-development/chat/controller/useDirectProjectChatController.test.tsx @@ -2,6 +2,7 @@ import { act, cleanup, renderHook, waitFor } from '@testing-library/react'; import { afterEach, describe, expect, it, vi } from 'vitest'; +import type { TauriInvoke } from '../../../../app/types'; import type { HistorySlice } from '../generated/HistorySlice'; import type { ThreadItem } from '../generated/ThreadItem'; import { useDirectProjectChatController } from './useDirectProjectChatController'; @@ -32,6 +33,7 @@ function slice( */ function installDeferredHistoryInvoke() { const requests: SliceRequest[] = []; + // `vi.fn` 的返回类型是固定签名,装不进 `window.__TAURI__.core.invoke` 的泛型签名,这里显式转换。 const invoke = vi.fn( async (command: string, args?: Record) => { if (command !== 'read_direct_project_history_slice') return undefined; @@ -44,7 +46,7 @@ function installDeferredHistoryInvoke() { }); }); }, - ); + ) as unknown as TauriInvoke; window.__TAURI__ = { core: { invoke } }; return { /** 取出一条挂起的读取;没有就等到出现为止。 */