Skip to content

Commit

Permalink
[v4] Fix(types): external module type error (CompoundedComponent) (#3…
Browse files Browse the repository at this point in the history
…9058)

* fix(types): external module type error (CompoundedComponent)

* feat(types): export CountdownProps
  • Loading branch information
wangcch committed Jan 3, 2023
1 parent c5198a4 commit ae62ef7
Show file tree
Hide file tree
Showing 29 changed files with 93 additions and 88 deletions.
6 changes: 3 additions & 3 deletions components/alert/index.tsx
Expand Up @@ -99,11 +99,11 @@ const CloseIcon: React.FC<CloseIconProps> = props => {
) : null;
};

interface AlertInterface extends React.FC<AlertProps> {
type CompoundedComponent = React.FC<AlertProps> & {
ErrorBoundary: typeof ErrorBoundary;
}
};

const Alert: AlertInterface = ({
const Alert: CompoundedComponent = ({
description,
prefixCls: customizePrefixCls,
message,
Expand Down
6 changes: 3 additions & 3 deletions components/anchor/index.tsx
Expand Up @@ -6,11 +6,11 @@ export { AnchorLinkProps } from './AnchorLink';

type InternalAnchorType = typeof InternalAnchor;

interface AnchorInterface extends InternalAnchorType {
type CompoundedComponent = InternalAnchorType & {
Link: typeof AnchorLink;
}
};

const Anchor = InternalAnchor as AnchorInterface;
const Anchor = InternalAnchor as CompoundedComponent;

Anchor.Link = AnchorLink;
export default Anchor;
4 changes: 2 additions & 2 deletions components/badge/index.tsx
Expand Up @@ -12,9 +12,9 @@ import { isPresetColor } from './utils';

export { ScrollNumberProps } from './ScrollNumber';

interface CompoundedComponent extends React.FC<BadgeProps> {
type CompoundedComponent = React.FC<BadgeProps> & {
Ribbon: typeof Ribbon;
}
};

export interface BadgeProps {
/** Number to show in badge */
Expand Down
6 changes: 3 additions & 3 deletions components/breadcrumb/Breadcrumb.tsx
Expand Up @@ -67,12 +67,12 @@ const addChildPath = (paths: string[], childPath: string, params: any) => {
return originalPaths;
};

interface BreadcrumbInterface extends React.FC<BreadcrumbProps> {
type CompoundedComponent = React.FC<BreadcrumbProps> & {
Item: typeof BreadcrumbItem;
Separator: typeof BreadcrumbSeparator;
}
};

const Breadcrumb: BreadcrumbInterface = ({
const Breadcrumb: CompoundedComponent = ({
prefixCls: customizePrefixCls,
separator = '/',
style,
Expand Down
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
7 changes: 4 additions & 3 deletions components/button/button.tsx
Expand Up @@ -128,12 +128,13 @@ export type NativeButtonProps = {

export type ButtonProps = Partial<AnchorButtonProps & NativeButtonProps>;

interface CompoundedComponent
extends React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLElement>> {
type CompoundedComponent = React.ForwardRefExoticComponent<
ButtonProps & React.RefAttributes<HTMLElement>
> & {
Group: typeof Group;
/** @internal */
__ANT_BUTTON: boolean;
}
};

type Loading = number | boolean;

Expand Down
7 changes: 4 additions & 3 deletions components/checkbox/index.tsx
Expand Up @@ -6,12 +6,13 @@ import Group from './Group';
export { CheckboxChangeEvent, CheckboxProps } from './Checkbox';
export { CheckboxGroupProps, CheckboxOptionType } from './Group';

interface CompoundedComponent
extends React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>> {
type CompoundedComponent = React.ForwardRefExoticComponent<
CheckboxProps & React.RefAttributes<HTMLInputElement>
> & {
Group: typeof Group;
/** @internal */
__ANT_CHECKBOX: boolean;
}
};

const Checkbox = InternalCheckbox as CompoundedComponent;

Expand Down
6 changes: 3 additions & 3 deletions components/collapse/Collapse.tsx
Expand Up @@ -48,11 +48,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 @@ -27,12 +27,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,11 +82,11 @@ export interface DropdownProps {
onVisibleChange?: (open: boolean) => void;
}

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

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 @@ -23,12 +23,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 @@ -385,11 +385,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 @@ -9,7 +9,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 @@ -20,9 +20,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
7 changes: 4 additions & 3 deletions components/input/index.tsx
Expand Up @@ -12,13 +12,14 @@ export { PasswordProps } from './Password';
export { SearchProps } from './Search';
export { TextAreaProps } from './TextArea';

interface CompoundedComponent
extends React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>> {
type CompoundedComponent = React.ForwardRefExoticComponent<
InputProps & React.RefAttributes<InputRef>
> & {
Group: typeof Group;
Search: typeof Search;
TextArea: typeof TextArea;
Password: typeof Password;
}
};

const Input = InternalInput as CompoundedComponent;

Expand Down
6 changes: 3 additions & 3 deletions components/layout/index.tsx
Expand Up @@ -6,14 +6,14 @@ export { SiderProps } from './Sider';

type InternalLayoutType = typeof InternalLayout;

interface LayoutType extends InternalLayoutType {
type CompoundedComponent = InternalLayoutType & {
Header: typeof Header;
Footer: typeof Footer;
Content: typeof Content;
Sider: typeof Sider;
}
};

const Layout = InternalLayout as LayoutType;
const Layout = InternalLayout as CompoundedComponent;

Layout.Header = Header;
Layout.Footer = Footer;
Expand Down
11 changes: 5 additions & 6 deletions components/mentions/index.tsx
Expand Up @@ -23,9 +23,7 @@ function loadingFilterOption() {

export type MentionPlacement = 'top' | 'bottom';

export type {
DataDrivenOptionProps as MentionsOptionProps,
} from 'rc-mentions/lib/Mentions';
export type { DataDrivenOptionProps as MentionsOptionProps } from 'rc-mentions/lib/Mentions';

export interface OptionProps {
value: string;
Expand Down Expand Up @@ -55,11 +53,12 @@ interface MentionsEntity {
value: string;
}

interface CompoundedComponent
extends React.ForwardRefExoticComponent<MentionProps & React.RefAttributes<MentionsRef>> {
type CompoundedComponent = React.ForwardRefExoticComponent<
MentionProps & React.RefAttributes<MentionsRef>
> & {
Option: typeof Option;
getMentions: (value: string, config?: MentionsConfig) => MentionsEntity[];
}
};

const InternalMentions: React.ForwardRefRenderFunction<MentionsRef, MentionProps> = (
{
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
8 changes: 5 additions & 3 deletions components/radio/index.tsx
Expand Up @@ -14,13 +14,15 @@ export {
RadioProps,
} from './interface';
export { Button, Group };
interface CompoundedComponent
extends React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLElement>> {

type CompoundedComponent = React.ForwardRefExoticComponent<
RadioProps & React.RefAttributes<HTMLElement>
> & {
Group: typeof Group;
Button: typeof Button;
/** @internal */
__ANT_RADIO: boolean;
}
};

const Radio = InternalRadio as CompoundedComponent;
Radio.Button = Button;
Expand Down
8 changes: 4 additions & 4 deletions components/skeleton/Skeleton.tsx
Expand Up @@ -14,7 +14,7 @@ import type { SkeletonTitleProps } from './Title';
import Title from './Title';

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

export interface SkeletonProps {
active?: boolean;
Expand Down Expand Up @@ -75,15 +75,15 @@ function getParagraphBasicProps(hasAvatar: boolean, hasTitle: boolean): Skeleton
return basicProps;
}

interface CompoundedComponent {
type CompoundedComponent = {
Button: typeof SkeletonButton;
Avatar: typeof SkeletonAvatar;
Input: typeof SkeletonInput;
Image: typeof SkeletonImage;
Node: typeof SkeletonNode;
}
};

const Skeleton: React.FC<SkeletonProps> & CompoundedComponent = props => {
const Skeleton: React.FC<SkeletonProps> & CompoundedComponent = (props) => {
const {
prefixCls: customizePrefixCls,
loading,
Expand Down
4 changes: 2 additions & 2 deletions components/space/index.tsx
Expand Up @@ -146,9 +146,9 @@ const Space: React.FC<SpaceProps> = props => {
);
};

interface CompoundedComponent extends React.FC<SpaceProps> {
type CompoundedComponent = React.FC<SpaceProps> & {
Compact: typeof Compact;
}
};

const CompoundedSpace = Space as CompoundedComponent;
CompoundedSpace.Compact = Compact;
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 @@ -8,9 +8,9 @@ import type Countdown from './Countdown';
import StatisticNumber from './Number';
import type { FormatConfig, valueType } from './utils';

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

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

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

export default WrapperStatistic;

0 comments on commit ae62ef7

Please sign in to comment.