From 585444c50c99fd2629680f7d01ef06a270431bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Thu, 25 Jul 2024 11:21:51 +0800 Subject: [PATCH] chore: fix type annotations (#6600) --- .../app/configuration/config-var/index.tsx | 2 +- .../prompt-mode/advanced-mode-waring.tsx | 2 -- .../notion-page-selector-modal/index.tsx | 8 ++++---- web/app/components/base/select/index.tsx | 2 +- web/app/components/explore/category.tsx | 2 +- .../model-provider-page/declarations.ts | 1 + web/app/components/header/dataset-nav/index.tsx | 7 ++++--- .../components/header/nav/nav-selector/index.tsx | 4 ++-- web/app/components/tools/provider/card.tsx | 2 +- web/app/components/tools/provider/detail.tsx | 2 +- web/app/components/tools/workflow-tool/index.tsx | 2 +- .../workflow/block-selector/index-bar.tsx | 14 ++++++++++---- 12 files changed, 27 insertions(+), 21 deletions(-) diff --git a/web/app/components/app/configuration/config-var/index.tsx b/web/app/components/app/configuration/config-var/index.tsx index a4f8b6839f..9ef624ed97 100644 --- a/web/app/components/app/configuration/config-var/index.tsx +++ b/web/app/components/app/configuration/config-var/index.tsx @@ -96,7 +96,7 @@ const ConfigVar: FC = ({ promptVariables, readonly, onPromptVar ...rest, type: type === InputVarType.textInput ? 'string' : type, key: variable, - name: label, + name: label as string, } if (payload.type === InputVarType.textInput) diff --git a/web/app/components/app/configuration/prompt-mode/advanced-mode-waring.tsx b/web/app/components/app/configuration/prompt-mode/advanced-mode-waring.tsx index 759a15213d..6fb58ba9a1 100644 --- a/web/app/components/app/configuration/prompt-mode/advanced-mode-waring.tsx +++ b/web/app/components/app/configuration/prompt-mode/advanced-mode-waring.tsx @@ -4,7 +4,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { useContext } from 'use-context-selector' import I18n from '@/context/i18n' -import { FlipBackward } from '@/app/components/base/icons/src/vender/line/arrows' import { LanguagesSupported } from '@/i18n/language' type Props = { onReturnToSimpleMode: () => void @@ -38,7 +37,6 @@ const AdvancedModeWarning: FC = ({ onClick={onReturnToSimpleMode} className='shrink-0 flex items-center h-6 px-2 bg-indigo-600 shadow-xs border border-gray-200 rounded-lg text-white text-xs font-semibold cursor-pointer space-x-1' > -
{t('appDebug.promptMode.switchBack')}
void - onSave: (selectedPages: NotionPageSelectorValue[]) => void + onSave: (selectedPages: NotionPage[]) => void datasetId: string } const NotionPageSelectorModal = ({ @@ -20,12 +20,12 @@ const NotionPageSelectorModal = ({ datasetId, }: NotionPageSelectorModalProps) => { const { t } = useTranslation() - const [selectedPages, setSelectedPages] = useState([]) + const [selectedPages, setSelectedPages] = useState([]) const handleClose = () => { onClose() } - const handleSelectPage = (newSelectedPages: NotionPageSelectorValue[]) => { + const handleSelectPage = (newSelectedPages: NotionPage[]) => { setSelectedPages(newSelectedPages) } const handleSave = () => { diff --git a/web/app/components/base/select/index.tsx b/web/app/components/base/select/index.tsx index 24da8855fa..dee983690b 100644 --- a/web/app/components/base/select/index.tsx +++ b/web/app/components/base/select/index.tsx @@ -191,7 +191,7 @@ const SimpleSelect: FC = ({ onClick={(e) => { e.stopPropagation() setSelectedItem(null) - onSelect({ value: null }) + onSelect({ name: '', value: '' }) }} className="h-5 w-5 text-gray-400 cursor-pointer" aria-hidden="false" diff --git a/web/app/components/explore/category.tsx b/web/app/components/explore/category.tsx index 2b6cfbd9be..cf655c5333 100644 --- a/web/app/components/explore/category.tsx +++ b/web/app/components/explore/category.tsx @@ -28,7 +28,7 @@ const Category: FC = ({ allCategoriesEn, }) => { const { t } = useTranslation() - const isAllCategories = !list.includes(value) + const isAllCategories = !list.includes(value as AppCategory) const itemClassName = (isSelected: boolean) => cn( 'flex items-center px-3 py-[7px] h-[32px] rounded-lg border-[0.5px] border-transparent text-gray-700 font-medium leading-[18px] cursor-pointer hover:bg-gray-200', diff --git a/web/app/components/header/account-setting/model-provider-page/declarations.ts b/web/app/components/header/account-setting/model-provider-page/declarations.ts index abc81262b9..1547032163 100644 --- a/web/app/components/header/account-setting/model-provider-page/declarations.ts +++ b/web/app/components/header/account-setting/model-provider-page/declarations.ts @@ -12,6 +12,7 @@ export enum FormTypeEnum { secretInput = 'secret-input', select = 'select', radio = 'radio', + boolean = 'boolean', files = 'files', } diff --git a/web/app/components/header/dataset-nav/index.tsx b/web/app/components/header/dataset-nav/index.tsx index f415658eee..abf76608a8 100644 --- a/web/app/components/header/dataset-nav/index.tsx +++ b/web/app/components/header/dataset-nav/index.tsx @@ -11,6 +11,7 @@ import useSWR from 'swr' import useSWRInfinite from 'swr/infinite' import { flatten } from 'lodash-es' import Nav from '../nav' +import type { NavItem } from '../nav/nav-selector' import { fetchDatasetDetail, fetchDatasets } from '@/service/datasets' import type { DataSetListResponse } from '@/models/datasets' @@ -31,7 +32,7 @@ const DatasetNav = () => { datasetId, } : null, - apiParams => fetchDatasetDetail(apiParams.datasetId)) + apiParams => fetchDatasetDetail(apiParams.datasetId as string)) const { data: datasetsData, setSize } = useSWRInfinite(datasetId ? getKey : () => null, fetchDatasets, { revalidateFirstPage: false, revalidateAll: true }) const datasetItems = flatten(datasetsData?.map(datasetData => datasetData.data)) @@ -46,14 +47,14 @@ const DatasetNav = () => { text={t('common.menus.datasets')} activeSegment='datasets' link='/datasets' - curNav={currentDataset} + curNav={currentDataset as Omit} navs={datasetItems.map(dataset => ({ id: dataset.id, name: dataset.name, link: `/datasets/${dataset.id}/documents`, icon: dataset.icon, icon_background: dataset.icon_background, - }))} + })) as NavItem[]} createText={t('common.menus.newDataset')} onCreate={() => router.push('/datasets/create')} onLoadmore={handleLoadmore} diff --git a/web/app/components/header/nav/nav-selector/index.tsx b/web/app/components/header/nav/nav-selector/index.tsx index 51192c6580..26f538d72d 100644 --- a/web/app/components/header/nav/nav-selector/index.tsx +++ b/web/app/components/header/nav/nav-selector/index.tsx @@ -23,13 +23,13 @@ export type NavItem = { link: string icon: string icon_background: string - mode: string + mode?: string } export type INavSelectorProps = { navs: NavItem[] curNav?: Omit createText: string - isApp: boolean + isApp?: boolean onCreate: (state: string) => void onLoadmore?: () => void } diff --git a/web/app/components/tools/provider/card.tsx b/web/app/components/tools/provider/card.tsx index 7f87d65e3a..6a688186cf 100644 --- a/web/app/components/tools/provider/card.tsx +++ b/web/app/components/tools/provider/card.tsx @@ -36,7 +36,7 @@ const ProviderCard = ({ }, [collection.labels, labelList, language]) return ( -
+
{typeof collection.icon === 'string' && ( diff --git a/web/app/components/tools/provider/detail.tsx b/web/app/components/tools/provider/detail.tsx index ee02e4966d..546b9cd9a1 100644 --- a/web/app/components/tools/provider/detail.tsx +++ b/web/app/components/tools/provider/detail.tsx @@ -85,7 +85,7 @@ const ProviderDetail = ({ const [customCollection, setCustomCollection] = useState(null) const [isShowEditCollectionToolModal, setIsShowEditCustomCollectionModal] = useState(false) const [showConfirmDelete, setShowConfirmDelete] = useState(false) - const [deleteAction, setDeleteAction] = useState(null) + const [deleteAction, setDeleteAction] = useState('') const doUpdateCustomToolCollection = async (data: CustomCollectionBackend) => { await updateCustomCollection(data) onRefreshData() diff --git a/web/app/components/tools/workflow-tool/index.tsx b/web/app/components/tools/workflow-tool/index.tsx index 436b2c55ab..0f9fe4c4c1 100644 --- a/web/app/components/tools/workflow-tool/index.tsx +++ b/web/app/components/tools/workflow-tool/index.tsx @@ -173,7 +173,7 @@ const WorkflowToolAsModal: FC = ({
{t('tools.createTool.description')}