fix: type hiint dispatch stateupdater

This commit is contained in:
2024-10-14 17:22:57 +08:00
parent 6df6ad031a
commit f5d43ec4b9
4 changed files with 8 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
import { Tr, langCodeContext, LANG_OPTIONS } from "./translate";
import structuredClone from "@ungap/structured-clone";
import { createRef } from "preact";
import { StateUpdater, useEffect, useState } from "preact/hooks";
import { StateUpdater, useEffect, useState, Dispatch } from "preact/hooks";
import {
ChatStore,
ChatStoreMessage,
@@ -55,7 +55,7 @@ export default function ChatBOX(props: {
chatStore: ChatStore;
setChatStore: (cs: ChatStore) => void;
selectedChatIndex: number;
setSelectedChatIndex: StateUpdater<number>;
setSelectedChatIndex: Dispatch<StateUpdater<number>>;
}) {
const { chatStore, setChatStore } = props;
// prevent error

View File

@@ -1,5 +1,5 @@
import { Tr, langCodeContext, LANG_OPTIONS, tr } from "./translate";
import { useState, useEffect, StateUpdater } from "preact/hooks";
import { useState, useEffect, StateUpdater,Dispatch } from "preact/hooks";
import { ChatStore, ChatStoreMessage } from "./app";
import { calculate_token_length, getMessageText } from "./chatgpt";
import { isVailedJSON } from "./message";
@@ -9,7 +9,7 @@ import { EditMessageDetail } from "./editMessageDetail";
interface EditMessageProps {
chat: ChatStoreMessage;
chatStore: ChatStore;
setShowEdit: StateUpdater<boolean>;
setShowEdit: Dispatch<StateUpdater<boolean>>;
setChatStore: (cs: ChatStore) => void;
}
export function EditMessage(props: EditMessageProps) {

View File

@@ -1,6 +1,6 @@
import { IDBPDatabase } from "idb";
import { ChatStore } from "./app";
import { StateUpdater, useRef, useState } from "preact/hooks";
import { StateUpdater, useRef, useState, Dispatch } from "preact/hooks";
interface ChatStoreSearchResult {
key: IDBValidKey;
@@ -11,7 +11,7 @@ interface ChatStoreSearchResult {
export default function Search(props: {
db: Promise<IDBPDatabase<ChatStore>>;
setSelectedChatIndex: StateUpdater<number>;
setSelectedChatIndex: Dispatch<StateUpdater<number>>;
chatStore: ChatStore;
setShow: (show: boolean) => void;
}) {

View File

@@ -1,5 +1,5 @@
import { createRef } from "preact";
import { StateUpdater, useContext, useEffect, useState } from "preact/hooks";
import { StateUpdater, useContext, useEffect, useState, Dispatch } from "preact/hooks";
import {
ChatStore,
TemplateAPI,
@@ -414,7 +414,7 @@ const Choice = (props: {
export default (props: {
chatStore: ChatStore;
setChatStore: (cs: ChatStore) => void;
setShow: StateUpdater<boolean>;
setShow: Dispatch<StateUpdater<boolean>>;
selectedChatStoreIndex: number;
templates: TemplateChatStore[];
setTemplates: (templates: TemplateChatStore[]) => void;