Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(type): replace interface with type for export component #39060

Merged
merged 1 commit into from Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/breadcrumb/BreadcrumbItem.tsx
Expand Up @@ -19,10 +19,10 @@ export interface BreadcrumbItemProps {
/** @deprecated Please use `menu` instead */
overlay?: DropdownProps['overlay'];
}
interface BreadcrumbItemInterface extends React.FC<BreadcrumbItemProps> {
type CompoundedComponent = React.FC<BreadcrumbItemProps> & {
__ANT_BREADCRUMB_ITEM: boolean;
}
const BreadcrumbItem: BreadcrumbItemInterface = (props) => {
};
const BreadcrumbItem: CompoundedComponent = (props) => {
const {
prefixCls: customizePrefixCls,
separator = '/',
Expand Down
6 changes: 3 additions & 3 deletions components/breadcrumb/BreadcrumbSeparator.tsx
@@ -1,12 +1,12 @@
import * as React from 'react';
import { ConfigContext } from '../config-provider';

interface BreadcrumbSeparatorInterface extends React.FC<{ children?: React.ReactNode }> {
type CompoundedComponent = React.FC<{ children?: React.ReactNode }> & {
/** @internal */
__ANT_BREADCRUMB_SEPARATOR: boolean;
}
};

const BreadcrumbSeparator: BreadcrumbSeparatorInterface = ({ children }) => {
const BreadcrumbSeparator: CompoundedComponent = ({ children }) => {
const { getPrefixCls } = React.useContext(ConfigContext);
const prefixCls = getPrefixCls('breadcrumb');

Expand Down
6 changes: 3 additions & 3 deletions components/collapse/Collapse.tsx
Expand Up @@ -50,11 +50,11 @@ interface PanelProps {
collapsible?: CollapsibleType;
}

interface CollapseInterface extends React.FC<CollapseProps> {
type CompoundedComponent = React.FC<CollapseProps> & {
Panel: typeof CollapsePanel;
}
};

const Collapse: CollapseInterface = (props) => {
const Collapse: CompoundedComponent = (props) => {
const { getPrefixCls, direction } = React.useContext(ConfigContext);
const {
prefixCls: customizePrefixCls,
Expand Down
6 changes: 3 additions & 3 deletions components/dropdown/dropdown-button.tsx
Expand Up @@ -28,12 +28,12 @@ export interface DropdownButtonProps extends ButtonGroupProps, DropdownProps {
buttonsRender?: (buttons: React.ReactNode[]) => React.ReactNode[];
}

interface DropdownButtonInterface extends React.FC<DropdownButtonProps> {
type CompoundedComponent = React.FC<DropdownButtonProps> & {
/** @internal */
__ANT_BUTTON: boolean;
}
};

const DropdownButton: DropdownButtonInterface = (props) => {
const DropdownButton: CompoundedComponent = (props) => {
const {
getPopupContainer: getContextPopupContainer,
getPrefixCls,
Expand Down
6 changes: 3 additions & 3 deletions components/dropdown/dropdown.tsx
Expand Up @@ -82,12 +82,12 @@ export interface DropdownProps {
onVisibleChange?: (open: boolean) => void;
}

interface DropdownInterface extends React.FC<DropdownProps> {
type CompoundedComponent = React.FC<DropdownProps> & {
Button: typeof DropdownButton;
_InternalPanelDoNotUseOrYouWillBeFired: typeof WrapPurePanel;
}
};

const Dropdown: DropdownInterface = (props) => {
const Dropdown: CompoundedComponent = (props) => {
const {
getPopupContainer: getContextPopupContainer,
getPrefixCls,
Expand Down
6 changes: 3 additions & 3 deletions components/empty/index.tsx
Expand Up @@ -25,12 +25,12 @@ export interface EmptyProps {
children?: React.ReactNode;
}

interface EmptyType extends React.FC<EmptyProps> {
type CompoundedComponent = React.FC<EmptyProps> & {
PRESENTED_IMAGE_DEFAULT: React.ReactNode;
PRESENTED_IMAGE_SIMPLE: React.ReactNode;
}
};

const Empty: EmptyType = ({
const Empty: CompoundedComponent = ({
className,
prefixCls: customizePrefixCls,
image = defaultEmptyImg,
Expand Down
6 changes: 3 additions & 3 deletions components/form/FormItem/index.tsx
Expand Up @@ -393,11 +393,11 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea

type InternalFormItemType = typeof InternalFormItem;

interface FormItemInterface extends InternalFormItemType {
type CompoundedComponent = InternalFormItemType & {
useStatus: typeof useFormItemStatus;
}
};

const FormItem = InternalFormItem as FormItemInterface;
const FormItem = InternalFormItem as CompoundedComponent;
FormItem.useStatus = useFormItemStatus;

export default FormItem;
6 changes: 3 additions & 3 deletions components/form/index.tsx
Expand Up @@ -13,7 +13,7 @@ import useFormInstance from './hooks/useFormInstance';

type InternalFormType = typeof InternalForm;

interface FormInterface extends InternalFormType {
type CompoundedComponent = InternalFormType & {
useForm: typeof useForm;
useFormInstance: typeof useFormInstance;
useWatch: typeof useWatch;
Expand All @@ -24,9 +24,9 @@ interface FormInterface extends InternalFormType {

/** @deprecated Only for warning usage. Do not use. */
create: () => void;
}
};

const Form = InternalForm as FormInterface;
const Form = InternalForm as CompoundedComponent;

Form.Item = Item;
Form.List = List;
Expand Down
8 changes: 4 additions & 4 deletions components/pagination/Select.tsx
Expand Up @@ -2,12 +2,12 @@ import * as React from 'react';
import type { SelectProps } from '../select';
import Select from '../select';

interface MiniOrMiddleSelectInterface extends React.FC<SelectProps> {
type CompoundedComponent = React.FC<SelectProps> & {
Option: typeof Select.Option;
}
};

const MiniSelect: MiniOrMiddleSelectInterface = (props) => <Select {...props} size="small" />;
const MiddleSelect: MiniOrMiddleSelectInterface = (props) => <Select {...props} size="middle" />;
const MiniSelect: CompoundedComponent = (props) => <Select {...props} size="small" />;
const MiddleSelect: CompoundedComponent = (props) => <Select {...props} size="middle" />;

MiniSelect.Option = Select.Option;
MiddleSelect.Option = Select.Option;
Expand Down
2 changes: 1 addition & 1 deletion components/skeleton/Skeleton.tsx
Expand Up @@ -16,7 +16,7 @@ import Title from './Title';
import useStyle from './style';

/* This only for skeleton internal. */
interface SkeletonAvatarProps extends Omit<AvatarProps, 'active'> {}
type SkeletonAvatarProps = Omit<AvatarProps, 'active'>;

export interface SkeletonProps {
active?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion components/statistic/Countdown.tsx
Expand Up @@ -8,7 +8,7 @@ import { formatCountdown } from './utils';

const REFRESH_INTERVAL = 1000 / 30;

interface CountdownProps extends StatisticProps {
export interface CountdownProps extends StatisticProps {
value?: countdownValueType;
format?: string;
onFinish?: () => void;
Expand Down
6 changes: 3 additions & 3 deletions components/statistic/Statistic.tsx
Expand Up @@ -10,9 +10,9 @@ import type { FormatConfig, valueType } from './utils';

import useStyle from './style';

interface StatisticComponent {
type CompoundedComponent = {
Countdown: typeof Countdown;
}
};

export interface StatisticProps extends FormatConfig {
prefixCls?: string;
Expand Down Expand Up @@ -81,6 +81,6 @@ const Statistic: React.FC<StatisticProps & ConfigConsumerProps> = (props) => {

const WrapperStatistic = withConfigConsumer<StatisticProps>({
prefixCls: 'statistic',
})<StatisticComponent>(Statistic);
})<CompoundedComponent>(Statistic);

export default WrapperStatistic;