@@ -31,7 +31,7 @@ export interface Message {
3131}
3232
3333interface ChatModuleProps {
34- onArtworkRecommendation ?: ( artwork : any ) => void ;
34+ onArtworkRecommendation ?: ( artwork : unknown ) => void ;
3535 externalMessage ?: string ;
3636 onMessageSent ?: ( ) => void ;
3737 onSavedMessagesChange ?: ( count : number , messages : Message [ ] ) => void ;
@@ -42,7 +42,7 @@ const API_BASE =
4242 import . meta. env . VITE_API_BASE_URL ?? "http://localhost:8000" ;
4343
4444/* ---- 유틸: 백엔드 호출 ------------------------------------------- */
45- type BackendResponse = { final_answer : string ; cards : any [ ] } ;
45+ type BackendResponse = { final_answer : string ; cards : unknown [ ] } ;
4646
4747const MAX_TURNS = 8 ; // 과도한 페이로드 방지
4848
@@ -155,10 +155,10 @@ export const ChatModule: React.FC<ChatModuleProps> = ({
155155 ]
156156 } ;
157157 setMessages ( prev => [ ...prev , assistantMessage ] ) ;
158- } catch ( err : any ) {
158+ } catch ( err : unknown ) {
159159 toast ( {
160160 title : '백엔드 오류' ,
161- description : err ? .message ?? '요청 중 오류가 발생했어요.' ,
161+ description : err instanceof Error ? err . message : '요청 중 오류가 발생했어요.' ,
162162 variant : 'destructive' ,
163163 } ) ;
164164 } finally {
@@ -172,7 +172,7 @@ export const ChatModule: React.FC<ChatModuleProps> = ({
172172 onMessageSent ( ) ;
173173 }
174174 }
175- } , [ externalMessage ] ) ;
175+ } , [ externalMessage , messages , onMessageSent ] ) ;
176176
177177 /* ---------------- 파생 ------------------------------ */
178178 const savedMessages = messages . filter ( ( msg ) => msg . isSaved ) ;
@@ -218,7 +218,7 @@ export const ChatModule: React.FC<ChatModuleProps> = ({
218218 } catch ( err : any ) {
219219 toast ( {
220220 title : '백엔드 오류' ,
221- description : err ? .message ?? '요청 중 오류가 발생했어요.' ,
221+ description : err instanceof Error ? err . message : '요청 중 오류가 발생했어요.' ,
222222 variant : 'destructive' ,
223223 } ) ;
224224 } finally {
@@ -252,7 +252,7 @@ const handleSuggestionClick = async (suggestion: string) => {
252252 } catch ( err : any ) {
253253 toast ( {
254254 title : '백엔드 오류' ,
255- description : err ? .message ?? '요청 중 오류가 발생했어요.' ,
255+ description : err instanceof Error ? err . message : '요청 중 오류가 발생했어요.' ,
256256 variant : 'destructive' ,
257257 } ) ;
258258 } finally {
0 commit comments