From 6834961dd178cef1fc7a891b18b122287920b4fc Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 20 Jun 2025 23:11:53 +0530 Subject: [PATCH] (fix:types) stricter in v19 --- frontend/src/components/ContextMenu.tsx | 6 +++--- frontend/src/components/DropdownMenu.tsx | 10 +++++----- frontend/src/components/MultiSelectPopup.tsx | 2 +- frontend/src/components/SourcesPopup.tsx | 2 +- frontend/src/components/ToolsPopup.tsx | 2 +- frontend/src/conversation/ConversationBubble.tsx | 2 +- frontend/src/hooks/index.ts | 4 ++-- frontend/src/settings/Documents.tsx | 6 +++--- frontend/src/settings/Tools.tsx | 4 ++-- frontend/src/upload/Upload.tsx | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/frontend/src/components/ContextMenu.tsx b/frontend/src/components/ContextMenu.tsx index 3713ffe6..6736fd7a 100644 --- a/frontend/src/components/ContextMenu.tsx +++ b/frontend/src/components/ContextMenu.tsx @@ -14,10 +14,10 @@ interface ContextMenuProps { isOpen: boolean; setIsOpen: (isOpen: boolean) => void; options: MenuOption[]; - anchorRef: React.RefObject; - className?: string; - position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'; + anchorRef: React.RefObject; + position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'; offset?: { x: number; y: number }; + className?: string; } export default function ContextMenu({ diff --git a/frontend/src/components/DropdownMenu.tsx b/frontend/src/components/DropdownMenu.tsx index 3fe85508..d40157f2 100644 --- a/frontend/src/components/DropdownMenu.tsx +++ b/frontend/src/components/DropdownMenu.tsx @@ -7,12 +7,12 @@ type DropdownMenuProps = { onSelect: (value: string) => void; defaultValue?: string; icon?: string; - isOpen?: boolean; - onOpenChange?: (isOpen: boolean) => void; - anchorRef?: React.RefObject; - className?: string; - position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'; + isOpen: boolean; + onOpenChange: (isOpen: boolean) => void; + anchorRef: React.RefObject; + position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'; offset?: { x: number; y: number }; + className?: string; }; export default function DropdownMenu({ diff --git a/frontend/src/components/MultiSelectPopup.tsx b/frontend/src/components/MultiSelectPopup.tsx index ef1ec41f..2047c12b 100644 --- a/frontend/src/components/MultiSelectPopup.tsx +++ b/frontend/src/components/MultiSelectPopup.tsx @@ -17,7 +17,7 @@ export type OptionType = { type MultiSelectPopupProps = { isOpen: boolean; onClose: () => void; - anchorRef: React.RefObject; + anchorRef: React.RefObject; options: OptionType[]; selectedIds: Set; onSelectionChange: (newSelectedIds: Set) => void; diff --git a/frontend/src/components/SourcesPopup.tsx b/frontend/src/components/SourcesPopup.tsx index bdfb7538..47bda538 100644 --- a/frontend/src/components/SourcesPopup.tsx +++ b/frontend/src/components/SourcesPopup.tsx @@ -16,7 +16,7 @@ import { ActiveState } from '../models/misc'; type SourcesPopupProps = { isOpen: boolean; onClose: () => void; - anchorRef: React.RefObject; + anchorRef: React.RefObject; handlePostDocumentSelect: (doc: Doc | null) => void; setUploadModalState: React.Dispatch>; }; diff --git a/frontend/src/components/ToolsPopup.tsx b/frontend/src/components/ToolsPopup.tsx index 4948bad6..b451ace6 100644 --- a/frontend/src/components/ToolsPopup.tsx +++ b/frontend/src/components/ToolsPopup.tsx @@ -14,7 +14,7 @@ import { useDarkTheme } from '../hooks'; interface ToolsPopupProps { isOpen: boolean; onClose: () => void; - anchorRef: React.RefObject; + anchorRef: React.RefObject; } export default function ToolsPopup({ diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 04800c83..13468f87 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -96,7 +96,7 @@ const ConversationBubble = forwardRef< const [isDislikeClicked, setIsDislikeClicked] = useState(false); const [activeTooltip, setActiveTooltip] = useState(null); const [isSidebarOpen, setIsSidebarOpen] = useState(false); - const editableQueryRef = useRef(null); + const editableQueryRef = useRef(null); const [isQuestionCollapsed, setIsQuestionCollapsed] = useState(true); useOutsideAlerter(editableQueryRef, () => setIsEditClicked(false), [], true); diff --git a/frontend/src/hooks/index.ts b/frontend/src/hooks/index.ts index 1b9f9b87..49e4cd55 100644 --- a/frontend/src/hooks/index.ts +++ b/frontend/src/hooks/index.ts @@ -1,7 +1,7 @@ import { useEffect, RefObject, useState } from 'react'; export function useOutsideAlerter( - ref: RefObject, + ref: RefObject, handler: () => void, additionalDeps: unknown[], handleEscapeKey?: boolean, @@ -30,7 +30,7 @@ export function useOutsideAlerter( document.removeEventListener('keydown', handleEscape); } }; - }, [ref, ...additionalDeps]); + }, [ref, handler, handleEscapeKey, ...additionalDeps]); } export function useMediaQuery() { diff --git a/frontend/src/settings/Documents.tsx b/frontend/src/settings/Documents.tsx index 5a733beb..b6a84e50 100644 --- a/frontend/src/settings/Documents.tsx +++ b/frontend/src/settings/Documents.tsx @@ -68,9 +68,9 @@ export default function Documents({ const [totalPages, setTotalPages] = useState(1); const [activeMenuId, setActiveMenuId] = useState(null); - const menuRefs = useRef<{ [key: string]: React.RefObject }>( - {}, - ); + const menuRefs = useRef<{ + [key: string]: React.RefObject; + }>({}); // Create or get a ref for each document wrapper div (not the td) const getMenuRef = (docId: string) => { diff --git a/frontend/src/settings/Tools.tsx b/frontend/src/settings/Tools.tsx index a3d37557..d387ce00 100644 --- a/frontend/src/settings/Tools.tsx +++ b/frontend/src/settings/Tools.tsx @@ -35,7 +35,7 @@ export default function Tools() { const [loading, setLoading] = React.useState(false); const [activeMenuId, setActiveMenuId] = React.useState(null); const menuRefs = React.useRef<{ - [key: string]: React.RefObject; + [key: string]: React.RefObject; }>({}); const [deleteModalState, setDeleteModalState] = React.useState('INACTIVE'); @@ -46,7 +46,7 @@ export default function Tools() { React.useEffect(() => { userTools.forEach((tool) => { if (!menuRefs.current[tool.id]) { - menuRefs.current[tool.id] = React.createRef(); + menuRefs.current[tool.id] = React.createRef(); } }); }, [userTools]); diff --git a/frontend/src/upload/Upload.tsx b/frontend/src/upload/Upload.tsx index 61a7bc47..3e5dd27a 100644 --- a/frontend/src/upload/Upload.tsx +++ b/frontend/src/upload/Upload.tsx @@ -194,7 +194,7 @@ function Upload({ }>(); const { t } = useTranslation(); - const setTimeoutRef = useRef(); + const setTimeoutRef = useRef(null); const urlOptions: { label: string; value: IngestorType }[] = [ { label: 'Crawler', value: 'crawler' },