From 35c7175398a761e4ba00886165214a63f2199fd6 Mon Sep 17 00:00:00 2001 From: Alexandr Buhlak <48954743+saha80@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:52:03 +0300 Subject: [PATCH] fix(#267): types annotations --- src/components/common/BaseCalendar/BaseCalendar.tsx | 7 +++---- src/components/common/BaseTable/BaseTable.styles.ts | 2 +- src/components/common/BaseTable/BaseTable.tsx | 9 ++++----- src/components/common/forms/BaseForm/BaseForm.tsx | 9 ++++----- .../BloodScreeningTable/BloodScreeningTable.styles.ts | 2 +- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/components/common/BaseCalendar/BaseCalendar.tsx b/src/components/common/BaseCalendar/BaseCalendar.tsx index 63bf8964..4d38f36d 100644 --- a/src/components/common/BaseCalendar/BaseCalendar.tsx +++ b/src/components/common/BaseCalendar/BaseCalendar.tsx @@ -1,9 +1,8 @@ -import { FC } from 'react'; -import type { CalendarProps } from 'antd'; -import type { Dayjs } from 'dayjs'; +import { ComponentProps, FC } from 'react'; +import type { Calendar } from 'antd'; import * as S from './BaseCalendar.styles'; -export type BaseCalendarProps = CalendarProps; +export type BaseCalendarProps = ComponentProps; export const BaseCalendar: FC = (props) => { return ; diff --git a/src/components/common/BaseTable/BaseTable.styles.ts b/src/components/common/BaseTable/BaseTable.styles.ts index 91c66f48..efc86a5e 100644 --- a/src/components/common/BaseTable/BaseTable.styles.ts +++ b/src/components/common/BaseTable/BaseTable.styles.ts @@ -85,4 +85,4 @@ export const Table = styled(AntdTable)` color: var(--disabled-color); } } -` as typeof AntdTable; +`; diff --git a/src/components/common/BaseTable/BaseTable.tsx b/src/components/common/BaseTable/BaseTable.tsx index 0589c0ec..a9c9eb85 100644 --- a/src/components/common/BaseTable/BaseTable.tsx +++ b/src/components/common/BaseTable/BaseTable.tsx @@ -1,12 +1,11 @@ -import { TableProps } from 'antd'; +import type { ComponentProps, FC } from 'react'; +import { Table } from 'antd'; import * as S from './BaseTable.styles'; // eslint-disable-next-line @typescript-eslint/no-explicit-any -type AnyRecord = Record; - -export type BaseTableProps = TableProps; +export type BaseTableProps = ComponentProps>; // TODO make generic! -export const BaseTable = (props: BaseTableProps): React.JSX.Element => { +export const BaseTable: FC = (props) => { return ; }; diff --git a/src/components/common/forms/BaseForm/BaseForm.tsx b/src/components/common/forms/BaseForm/BaseForm.tsx index 41e4eab8..5f6ed974 100644 --- a/src/components/common/forms/BaseForm/BaseForm.tsx +++ b/src/components/common/forms/BaseForm/BaseForm.tsx @@ -1,18 +1,17 @@ -import React, { ComponentProps } from 'react'; +import type { ComponentProps, FC } from 'react'; import { Form, FormInstance } from 'antd'; import { useTranslation } from 'react-i18next'; -import { ValidateErrorEntity } from 'rc-field-form/lib/interface'; import { BaseFormTitle } from '@app/components/common/forms/components/BaseFormTitle/BaseFormTitle'; import { BaseFormItem } from '@app/components/common/forms/components/BaseFormItem/BaseFormItem'; import { BaseFormList } from '@app/components/common/forms/components/BaseFormList/BaseFormList'; import { useFeedback } from '@app/hooks/useFeedback'; // eslint-disable-next-line @typescript-eslint/no-explicit-any -export type BaseFormProps = Omit, 'onFinish'> & { onFinish?: (values: any) => void }; +export type BaseFormProps = ComponentProps>; export type BaseFormInstance = FormInstance; -export interface BaseFormInterface extends React.FC { +export interface BaseFormInterface extends FC { Title: typeof BaseFormTitle; Item: typeof BaseFormItem; List: typeof BaseFormList; @@ -24,7 +23,7 @@ export const BaseForm: BaseFormInterface = ({ onFinishFailed, lay const { t } = useTranslation(); const { notification } = useFeedback(); - const onFinishFailedDefault = (error: ValidateErrorEntity) => { + const onFinishFailedDefault: typeof onFinishFailed = (error) => { notification.error({ message: t('common.error'), description: error.errorFields[0].errors, diff --git a/src/components/medical-dashboard/bloodScreeningCard/BloodScreeningTable/BloodScreeningTable.styles.ts b/src/components/medical-dashboard/bloodScreeningCard/BloodScreeningTable/BloodScreeningTable.styles.ts index 38a389a2..18f05b9c 100644 --- a/src/components/medical-dashboard/bloodScreeningCard/BloodScreeningTable/BloodScreeningTable.styles.ts +++ b/src/components/medical-dashboard/bloodScreeningCard/BloodScreeningTable/BloodScreeningTable.styles.ts @@ -27,7 +27,7 @@ export const Table = styled(BaseTable)` border: 0; cursor: pointer; } -` as typeof BaseTable; // todo: remove type assertion +`; export const Text = styled.span` color: var(--text-main-color);