From 00b79681a0350c72f0cc3c348c232f853ad82d91 Mon Sep 17 00:00:00 2001 From: lafay <2021211506@stu.hit.edu.cn> Date: Sat, 4 Apr 2026 00:43:09 +0800 Subject: [PATCH] refactor(types): add TypeScript type assertion for channel API response Add explicit type casting to handle potential channel data response formats, improving type safety and IDE autocomplete for Channel data structures. --- src/pages/Channels.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Channels.tsx b/src/pages/Channels.tsx index d40d01c..0ecd0d8 100644 --- a/src/pages/Channels.tsx +++ b/src/pages/Channels.tsx @@ -55,7 +55,7 @@ export default function Channels() { setLoading(true) try { const response = await channelsApi.getChannels() - const data = response.data.data + const data = response.data.data as Channel[] | { list: Channel[] } | undefined const list = Array.isArray(data) ? data : (data?.list || []) list.sort((a: Channel, b: Channel) => a.sort_order - b.sort_order) setChannels(list)