From aada865873ec5ee154272d3b5a022cc7ea57c57a Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Mon, 15 Aug 2022 10:05:03 +0800 Subject: [PATCH] fix: typescript error --- src/routes/chat/SessionList/index.tsx | 2 +- src/routes/chat/index.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/routes/chat/SessionList/index.tsx b/src/routes/chat/SessionList/index.tsx index 25208b63..e131a799 100644 --- a/src/routes/chat/SessionList/index.tsx +++ b/src/routes/chat/SessionList/index.tsx @@ -13,7 +13,7 @@ export interface ChatSession { unread?: number; } type Props = { - tempSession: ChatSession; + tempSession?: ChatSession; }; const SessionList: FC = ({ tempSession }) => { const [deleteId, setDeleteId] = useState(); diff --git a/src/routes/chat/index.tsx b/src/routes/chat/index.tsx index 50c4649c..ca4a8561 100644 --- a/src/routes/chat/index.tsx +++ b/src/routes/chat/index.tsx @@ -29,8 +29,13 @@ export default function ChatPage() { }; const tmpSession = sessionUids.findIndex((i) => i == user_id) > -1 - ? null - : { key: `user_${user_id}`, mid: null, unreads: 0, id: user_id, type: "user" }; + ? undefined + : { + key: `user_${user_id}`, + unreads: 0, + id: +user_id, + type: "user" as "user" | "channel" + }; // console.log("temp uid", tmpUid); const placeholderVisible = channel_id == 0 && user_id == 0; return (