Skip to content

Commit ae62ef7

Browse files
authoredJan 3, 2023
[v4] Fix(types): external module type error (CompoundedComponent) (#39058)
* fix(types): external module type error (CompoundedComponent) * feat(types): export CountdownProps
1 parent c5198a4 commit ae62ef7

File tree

29 files changed

+93
-88
lines changed

29 files changed

+93
-88
lines changed
 

‎components/alert/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ const CloseIcon: React.FC<CloseIconProps> = props => {
9999
) : null;
100100
};
101101

102-
interface AlertInterface extends React.FC<AlertProps> {
102+
type CompoundedComponent = React.FC<AlertProps> & {
103103
ErrorBoundary: typeof ErrorBoundary;
104-
}
104+
};
105105

106-
const Alert: AlertInterface = ({
106+
const Alert: CompoundedComponent = ({
107107
description,
108108
prefixCls: customizePrefixCls,
109109
message,

‎components/anchor/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ export { AnchorLinkProps } from './AnchorLink';
66

77
type InternalAnchorType = typeof InternalAnchor;
88

9-
interface AnchorInterface extends InternalAnchorType {
9+
type CompoundedComponent = InternalAnchorType & {
1010
Link: typeof AnchorLink;
11-
}
11+
};
1212

13-
const Anchor = InternalAnchor as AnchorInterface;
13+
const Anchor = InternalAnchor as CompoundedComponent;
1414

1515
Anchor.Link = AnchorLink;
1616
export default Anchor;

‎components/badge/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { isPresetColor } from './utils';
1212

1313
export { ScrollNumberProps } from './ScrollNumber';
1414

15-
interface CompoundedComponent extends React.FC<BadgeProps> {
15+
type CompoundedComponent = React.FC<BadgeProps> & {
1616
Ribbon: typeof Ribbon;
17-
}
17+
};
1818

1919
export interface BadgeProps {
2020
/** Number to show in badge */

‎components/breadcrumb/Breadcrumb.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ const addChildPath = (paths: string[], childPath: string, params: any) => {
6767
return originalPaths;
6868
};
6969

70-
interface BreadcrumbInterface extends React.FC<BreadcrumbProps> {
70+
type CompoundedComponent = React.FC<BreadcrumbProps> & {
7171
Item: typeof BreadcrumbItem;
7272
Separator: typeof BreadcrumbSeparator;
73-
}
73+
};
7474

75-
const Breadcrumb: BreadcrumbInterface = ({
75+
const Breadcrumb: CompoundedComponent = ({
7676
prefixCls: customizePrefixCls,
7777
separator = '/',
7878
style,

‎components/breadcrumb/BreadcrumbItem.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export interface BreadcrumbItemProps {
1919
/** @deprecated Please use `menu` instead */
2020
overlay?: DropdownProps['overlay'];
2121
}
22-
interface BreadcrumbItemInterface extends React.FC<BreadcrumbItemProps> {
22+
type CompoundedComponent = React.FC<BreadcrumbItemProps> & {
2323
__ANT_BREADCRUMB_ITEM: boolean;
24-
}
25-
const BreadcrumbItem: BreadcrumbItemInterface = (props) => {
24+
};
25+
const BreadcrumbItem: CompoundedComponent = (props) => {
2626
const {
2727
prefixCls: customizePrefixCls,
2828
separator = '/',

‎components/breadcrumb/BreadcrumbSeparator.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as React from 'react';
22
import { ConfigContext } from '../config-provider';
33

4-
interface BreadcrumbSeparatorInterface extends React.FC<{ children?: React.ReactNode }> {
4+
type CompoundedComponent = React.FC<{ children?: React.ReactNode }> & {
55
/** @internal */
66
__ANT_BREADCRUMB_SEPARATOR: boolean;
7-
}
7+
};
88

9-
const BreadcrumbSeparator: BreadcrumbSeparatorInterface = ({ children }) => {
9+
const BreadcrumbSeparator: CompoundedComponent = ({ children }) => {
1010
const { getPrefixCls } = React.useContext(ConfigContext);
1111
const prefixCls = getPrefixCls('breadcrumb');
1212

‎components/button/button.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,13 @@ export type NativeButtonProps = {
128128

129129
export type ButtonProps = Partial<AnchorButtonProps & NativeButtonProps>;
130130

131-
interface CompoundedComponent
132-
extends React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLElement>> {
131+
type CompoundedComponent = React.ForwardRefExoticComponent<
132+
ButtonProps & React.RefAttributes<HTMLElement>
133+
> & {
133134
Group: typeof Group;
134135
/** @internal */
135136
__ANT_BUTTON: boolean;
136-
}
137+
};
137138

138139
type Loading = number | boolean;
139140

‎components/checkbox/index.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import Group from './Group';
66
export { CheckboxChangeEvent, CheckboxProps } from './Checkbox';
77
export { CheckboxGroupProps, CheckboxOptionType } from './Group';
88

9-
interface CompoundedComponent
10-
extends React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>> {
9+
type CompoundedComponent = React.ForwardRefExoticComponent<
10+
CheckboxProps & React.RefAttributes<HTMLInputElement>
11+
> & {
1112
Group: typeof Group;
1213
/** @internal */
1314
__ANT_CHECKBOX: boolean;
14-
}
15+
};
1516

1617
const Checkbox = InternalCheckbox as CompoundedComponent;
1718

‎components/collapse/Collapse.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ interface PanelProps {
4848
collapsible?: CollapsibleType;
4949
}
5050

51-
interface CollapseInterface extends React.FC<CollapseProps> {
51+
type CompoundedComponent = React.FC<CollapseProps> & {
5252
Panel: typeof CollapsePanel;
53-
}
53+
};
5454

55-
const Collapse: CollapseInterface = props => {
55+
const Collapse: CompoundedComponent = (props) => {
5656
const { getPrefixCls, direction } = React.useContext(ConfigContext);
5757
const {
5858
prefixCls: customizePrefixCls,

‎components/dropdown/dropdown-button.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export interface DropdownButtonProps extends ButtonGroupProps, DropdownProps {
2727
buttonsRender?: (buttons: React.ReactNode[]) => React.ReactNode[];
2828
}
2929

30-
interface DropdownButtonInterface extends React.FC<DropdownButtonProps> {
30+
type CompoundedComponent = React.FC<DropdownButtonProps> & {
3131
/** @internal */
3232
__ANT_BUTTON: boolean;
33-
}
33+
};
3434

35-
const DropdownButton: DropdownButtonInterface = props => {
35+
const DropdownButton: CompoundedComponent = (props) => {
3636
const {
3737
getPopupContainer: getContextPopupContainer,
3838
getPrefixCls,

‎components/dropdown/dropdown.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ export interface DropdownProps {
8282
onVisibleChange?: (open: boolean) => void;
8383
}
8484

85-
interface DropdownInterface extends React.FC<DropdownProps> {
85+
type CompoundedComponent = React.FC<DropdownProps> & {
8686
Button: typeof DropdownButton;
87-
}
87+
};
8888

89-
const Dropdown: DropdownInterface = (props) => {
89+
const Dropdown: CompoundedComponent = (props) => {
9090
const {
9191
getPopupContainer: getContextPopupContainer,
9292
getPrefixCls,

‎components/empty/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export interface EmptyProps {
2323
children?: React.ReactNode;
2424
}
2525

26-
interface EmptyType extends React.FC<EmptyProps> {
26+
type CompoundedComponent = React.FC<EmptyProps> & {
2727
PRESENTED_IMAGE_DEFAULT: React.ReactNode;
2828
PRESENTED_IMAGE_SIMPLE: React.ReactNode;
29-
}
29+
};
3030

31-
const Empty: EmptyType = ({
31+
const Empty: CompoundedComponent = ({
3232
className,
3333
prefixCls: customizePrefixCls,
3434
image = defaultEmptyImg,

‎components/form/FormItem/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,11 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea
385385

386386
type InternalFormItemType = typeof InternalFormItem;
387387

388-
interface FormItemInterface extends InternalFormItemType {
388+
type CompoundedComponent = InternalFormItemType & {
389389
useStatus: typeof useFormItemStatus;
390-
}
390+
};
391391

392-
const FormItem = InternalFormItem as FormItemInterface;
392+
const FormItem = InternalFormItem as CompoundedComponent;
393393
FormItem.useStatus = useFormItemStatus;
394394

395395
export default FormItem;

‎components/form/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import useFormInstance from './hooks/useFormInstance';
99

1010
type InternalFormType = typeof InternalForm;
1111

12-
interface FormInterface extends InternalFormType {
12+
type CompoundedComponent = InternalFormType & {
1313
useForm: typeof useForm;
1414
useFormInstance: typeof useFormInstance;
1515
useWatch: typeof useWatch;
@@ -20,9 +20,9 @@ interface FormInterface extends InternalFormType {
2020

2121
/** @deprecated Only for warning usage. Do not use. */
2222
create: () => void;
23-
}
23+
};
2424

25-
const Form = InternalForm as FormInterface;
25+
const Form = InternalForm as CompoundedComponent;
2626

2727
Form.Item = Item;
2828
Form.List = List;

‎components/input/index.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ export { PasswordProps } from './Password';
1212
export { SearchProps } from './Search';
1313
export { TextAreaProps } from './TextArea';
1414

15-
interface CompoundedComponent
16-
extends React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>> {
15+
type CompoundedComponent = React.ForwardRefExoticComponent<
16+
InputProps & React.RefAttributes<InputRef>
17+
> & {
1718
Group: typeof Group;
1819
Search: typeof Search;
1920
TextArea: typeof TextArea;
2021
Password: typeof Password;
21-
}
22+
};
2223

2324
const Input = InternalInput as CompoundedComponent;
2425

‎components/layout/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ export { SiderProps } from './Sider';
66

77
type InternalLayoutType = typeof InternalLayout;
88

9-
interface LayoutType extends InternalLayoutType {
9+
type CompoundedComponent = InternalLayoutType & {
1010
Header: typeof Header;
1111
Footer: typeof Footer;
1212
Content: typeof Content;
1313
Sider: typeof Sider;
14-
}
14+
};
1515

16-
const Layout = InternalLayout as LayoutType;
16+
const Layout = InternalLayout as CompoundedComponent;
1717

1818
Layout.Header = Header;
1919
Layout.Footer = Footer;

‎components/mentions/index.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ function loadingFilterOption() {
2323

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

26-
export type {
27-
DataDrivenOptionProps as MentionsOptionProps,
28-
} from 'rc-mentions/lib/Mentions';
26+
export type { DataDrivenOptionProps as MentionsOptionProps } from 'rc-mentions/lib/Mentions';
2927

3028
export interface OptionProps {
3129
value: string;
@@ -55,11 +53,12 @@ interface MentionsEntity {
5553
value: string;
5654
}
5755

58-
interface CompoundedComponent
59-
extends React.ForwardRefExoticComponent<MentionProps & React.RefAttributes<MentionsRef>> {
56+
type CompoundedComponent = React.ForwardRefExoticComponent<
57+
MentionProps & React.RefAttributes<MentionsRef>
58+
> & {
6059
Option: typeof Option;
6160
getMentions: (value: string, config?: MentionsConfig) => MentionsEntity[];
62-
}
61+
};
6362

6463
const InternalMentions: React.ForwardRefRenderFunction<MentionsRef, MentionProps> = (
6564
{

‎components/pagination/Select.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import * as React from 'react';
22
import type { SelectProps } from '../select';
33
import Select from '../select';
44

5-
interface MiniOrMiddleSelectInterface extends React.FC<SelectProps> {
5+
type CompoundedComponent = React.FC<SelectProps> & {
66
Option: typeof Select.Option;
7-
}
7+
};
88

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

1212
MiniSelect.Option = Select.Option;
1313
MiddleSelect.Option = Select.Option;

‎components/radio/index.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ export {
1414
RadioProps,
1515
} from './interface';
1616
export { Button, Group };
17-
interface CompoundedComponent
18-
extends React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLElement>> {
17+
18+
type CompoundedComponent = React.ForwardRefExoticComponent<
19+
RadioProps & React.RefAttributes<HTMLElement>
20+
> & {
1921
Group: typeof Group;
2022
Button: typeof Button;
2123
/** @internal */
2224
__ANT_RADIO: boolean;
23-
}
25+
};
2426

2527
const Radio = InternalRadio as CompoundedComponent;
2628
Radio.Button = Button;

‎components/skeleton/Skeleton.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { SkeletonTitleProps } from './Title';
1414
import Title from './Title';
1515

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

1919
export interface SkeletonProps {
2020
active?: boolean;
@@ -75,15 +75,15 @@ function getParagraphBasicProps(hasAvatar: boolean, hasTitle: boolean): Skeleton
7575
return basicProps;
7676
}
7777

78-
interface CompoundedComponent {
78+
type CompoundedComponent = {
7979
Button: typeof SkeletonButton;
8080
Avatar: typeof SkeletonAvatar;
8181
Input: typeof SkeletonInput;
8282
Image: typeof SkeletonImage;
8383
Node: typeof SkeletonNode;
84-
}
84+
};
8585

86-
const Skeleton: React.FC<SkeletonProps> & CompoundedComponent = props => {
86+
const Skeleton: React.FC<SkeletonProps> & CompoundedComponent = (props) => {
8787
const {
8888
prefixCls: customizePrefixCls,
8989
loading,

‎components/space/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ const Space: React.FC<SpaceProps> = props => {
146146
);
147147
};
148148

149-
interface CompoundedComponent extends React.FC<SpaceProps> {
149+
type CompoundedComponent = React.FC<SpaceProps> & {
150150
Compact: typeof Compact;
151-
}
151+
};
152152

153153
const CompoundedSpace = Space as CompoundedComponent;
154154
CompoundedSpace.Compact = Compact;

‎components/statistic/Countdown.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { formatCountdown } from './utils';
88

99
const REFRESH_INTERVAL = 1000 / 30;
1010

11-
interface CountdownProps extends StatisticProps {
11+
export interface CountdownProps extends StatisticProps {
1212
value?: countdownValueType;
1313
format?: string;
1414
onFinish?: () => void;

‎components/statistic/Statistic.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import type Countdown from './Countdown';
88
import StatisticNumber from './Number';
99
import type { FormatConfig, valueType } from './utils';
1010

11-
interface StatisticComponent {
11+
type CompoundedComponent = {
1212
Countdown: typeof Countdown;
13-
}
13+
};
1414

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

7777
const WrapperStatistic = withConfigConsumer<StatisticProps>({
7878
prefixCls: 'statistic',
79-
})<StatisticComponent>(Statistic);
79+
})<CompoundedComponent>(Statistic);
8080

8181
export default WrapperStatistic;

‎components/steps/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ export interface StepsProps {
4141
items?: StepProps[];
4242
}
4343

44-
interface StepsType extends React.FC<StepsProps> {
44+
type CompoundedComponent = React.FC<StepsProps> & {
4545
Step: typeof RcSteps.Step;
46-
}
46+
};
4747

48-
const Steps: StepsType = props => {
48+
const Steps: CompoundedComponent = (props) => {
4949
const {
5050
percent,
5151
size,

‎components/switch/index.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ export interface SwitchProps {
3535
id?: string;
3636
}
3737

38-
interface CompoundedComponent
39-
extends React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLElement>> {
38+
type CompoundedComponent = React.ForwardRefExoticComponent<
39+
SwitchProps & React.RefAttributes<HTMLElement>
40+
> & {
4041
/** @internal */
4142
__ANT_SWITCH: boolean;
42-
}
43+
};
4344

4445
const Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(
4546
(

‎components/table/Table.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ const ForwardTable = React.forwardRef(InternalTable) as <RecordType extends obje
556556

557557
type InternalTableType = typeof ForwardTable;
558558

559-
interface TableInterface extends InternalTableType {
559+
type CompoundedComponent = InternalTableType & {
560560
SELECTION_COLUMN: typeof SELECTION_COLUMN;
561561
EXPAND_COLUMN: typeof RcTable.EXPAND_COLUMN;
562562
SELECTION_ALL: 'SELECT_ALL';
@@ -565,9 +565,9 @@ interface TableInterface extends InternalTableType {
565565
Column: typeof Column;
566566
ColumnGroup: typeof ColumnGroup;
567567
Summary: typeof Summary;
568-
}
568+
};
569569

570-
const Table = ForwardTable as TableInterface;
570+
const Table = ForwardTable as CompoundedComponent;
571571

572572
Table.SELECTION_COLUMN = SELECTION_COLUMN;
573573
Table.EXPAND_COLUMN = RcTable.EXPAND_COLUMN;

‎components/timeline/Timeline.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export interface TimelineProps {
1919
children?: React.ReactNode;
2020
}
2121

22-
interface TimelineType extends React.FC<TimelineProps> {
22+
type CompoundedComponent = React.FC<TimelineProps> & {
2323
Item: React.FC<TimelineItemProps>;
24-
}
24+
};
2525

26-
const Timeline: TimelineType = props => {
26+
const Timeline: CompoundedComponent = (props) => {
2727
const { getPrefixCls, direction } = React.useContext(ConfigContext);
2828
const {
2929
prefixCls: customizePrefixCls,

‎components/tree-select/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,14 @@ const TreeSelectRef = React.forwardRef(InternalTreeSelect) as <
246246

247247
type InternalTreeSelectType = typeof TreeSelectRef;
248248

249-
interface TreeSelectInterface extends InternalTreeSelectType {
249+
type CompoundedComponent = InternalTreeSelectType & {
250250
TreeNode: typeof TreeNode;
251251
SHOW_ALL: typeof SHOW_ALL;
252252
SHOW_PARENT: typeof SHOW_PARENT;
253253
SHOW_CHILD: typeof SHOW_CHILD;
254-
}
254+
};
255255

256-
const TreeSelect = TreeSelectRef as TreeSelectInterface;
256+
const TreeSelect = TreeSelectRef as CompoundedComponent;
257257

258258
TreeSelect.TreeNode = TreeNode;
259259
TreeSelect.SHOW_ALL = SHOW_ALL;

‎components/upload/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ export { DraggerProps } from './Dragger';
66
export { RcFile, UploadChangeParam, UploadFile, UploadListProps, UploadProps } from './interface';
77

88
type InternalUploadType = typeof InternalUpload;
9-
interface UploadInterface<T = any> extends InternalUploadType {
9+
type CompoundedComponent<T = any> = InternalUploadType & {
1010
<U extends T>(
1111
props: React.PropsWithChildren<UploadProps<U>> & React.RefAttributes<any>,
1212
): React.ReactElement;
1313
Dragger: typeof Dragger;
1414
LIST_IGNORE: string;
15-
}
15+
};
1616

17-
const Upload = InternalUpload as UploadInterface;
17+
const Upload = InternalUpload as CompoundedComponent;
1818
Upload.Dragger = Dragger;
1919
Upload.LIST_IGNORE = LIST_IGNORE;
2020

0 commit comments

Comments
 (0)
Please sign in to comment.