Skip to content

Commit

Permalink
fix(#267): types annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
saha80 authored and Rozhkow committed Dec 5, 2023
1 parent f2daa34 commit 35c7175
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/components/common/BaseCalendar/BaseCalendar.tsx
Original file line number Diff line number Diff line change
@@ -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<Dayjs>;
export type BaseCalendarProps = ComponentProps<typeof Calendar>;

export const BaseCalendar: FC<BaseCalendarProps> = (props) => {
return <S.Calendar {...props} />;
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/BaseTable/BaseTable.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ export const Table = styled(AntdTable)`
color: var(--disabled-color);
}
}
` as typeof AntdTable;
`;
9 changes: 4 additions & 5 deletions src/components/common/BaseTable/BaseTable.tsx
Original file line number Diff line number Diff line change
@@ -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<PropertyKey, any>;

export type BaseTableProps<T extends AnyRecord> = TableProps<T>;
export type BaseTableProps = ComponentProps<typeof Table<any>>;

// TODO make generic!
export const BaseTable = <T extends AnyRecord>(props: BaseTableProps<T>): React.JSX.Element => {
export const BaseTable: FC<BaseTableProps> = (props) => {
return <S.Table {...props} />;
};
9 changes: 4 additions & 5 deletions src/components/common/forms/BaseForm/BaseForm.tsx
Original file line number Diff line number Diff line change
@@ -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<ComponentProps<typeof Form>, 'onFinish'> & { onFinish?: (values: any) => void };
export type BaseFormProps = ComponentProps<typeof Form<any>>;

export type BaseFormInstance = FormInstance;

export interface BaseFormInterface<T> extends React.FC<T> {
export interface BaseFormInterface<T> extends FC<T> {
Title: typeof BaseFormTitle;
Item: typeof BaseFormItem;
List: typeof BaseFormList;
Expand All @@ -24,7 +23,7 @@ export const BaseForm: BaseFormInterface<BaseFormProps> = ({ onFinishFailed, lay
const { t } = useTranslation();
const { notification } = useFeedback();

const onFinishFailedDefault = (error: ValidateErrorEntity<unknown>) => {
const onFinishFailedDefault: typeof onFinishFailed = (error) => {
notification.error({
message: t('common.error'),
description: error.errorFields[0].errors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextProps>`
color: var(--text-main-color);
Expand Down

0 comments on commit 35c7175

Please sign in to comment.