From 7c02bdf1d5902006cc98449091adcad160c434ef Mon Sep 17 00:00:00 2001 From: wangcch Date: Sat, 19 Nov 2022 00:29:55 +0800 Subject: [PATCH] refactor(types): rename and replace internal CompoundedComponent type --- components/alert/index.tsx | 6 +++--- components/anchor/index.tsx | 6 +++--- components/breadcrumb/Breadcrumb.tsx | 6 +++--- components/layout/index.tsx | 6 +++--- components/steps/index.tsx | 6 +++--- components/table/Table.tsx | 6 +++--- components/timeline/Timeline.tsx | 6 +++--- components/tree-select/index.tsx | 6 +++--- components/upload/index.tsx | 6 +++--- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/components/alert/index.tsx b/components/alert/index.tsx index e253eb145fe8..308ef32709c3 100644 --- a/components/alert/index.tsx +++ b/components/alert/index.tsx @@ -91,11 +91,11 @@ const CloseIcon: React.FC = (props) => { ) : null; }; -interface AlertInterface extends React.FC { +type CompoundedComponent = React.FC & { ErrorBoundary: typeof ErrorBoundary; -} +}; -const Alert: AlertInterface = ({ +const Alert: CompoundedComponent = ({ description, prefixCls: customizePrefixCls, message, diff --git a/components/anchor/index.tsx b/components/anchor/index.tsx index bf76a8bd48b9..8fa68a45ec9b 100644 --- a/components/anchor/index.tsx +++ b/components/anchor/index.tsx @@ -6,11 +6,11 @@ export type { 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; diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index d3399a91d3a4..e34bd1e6b462 100755 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -69,12 +69,12 @@ const addChildPath = (paths: string[], childPath: string, params: any) => { return originalPaths; }; -interface BreadcrumbInterface extends React.FC { +type CompoundedComponent = React.FC & { Item: typeof BreadcrumbItem; Separator: typeof BreadcrumbSeparator; -} +}; -const Breadcrumb: BreadcrumbInterface = ({ +const Breadcrumb: CompoundedComponent = ({ prefixCls: customizePrefixCls, separator = '/', style, diff --git a/components/layout/index.tsx b/components/layout/index.tsx index e31a3f98cc99..1cd8a7a70e3c 100644 --- a/components/layout/index.tsx +++ b/components/layout/index.tsx @@ -6,14 +6,14 @@ export type { 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; diff --git a/components/steps/index.tsx b/components/steps/index.tsx index 8d1fddcaa3a2..b854662e7635 100644 --- a/components/steps/index.tsx +++ b/components/steps/index.tsx @@ -47,11 +47,11 @@ export interface StepsProps { items?: StepProps[]; } -interface StepsType extends React.FC { +type CompoundedComponent = React.FC & { Step: typeof RcSteps.Step; -} +}; -const Steps: StepsType = (props) => { +const Steps: CompoundedComponent = (props) => { const { percent, size, diff --git a/components/table/Table.tsx b/components/table/Table.tsx index a83805c616bc..bf579dd7a3f5 100644 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -554,7 +554,7 @@ const ForwardTable = React.forwardRef(InternalTable) as { +type CompoundedComponent = React.FC & { Item: React.FC; -} +}; -const Timeline: TimelineType = (props) => { +const Timeline: CompoundedComponent = (props) => { const { getPrefixCls, direction } = React.useContext(ConfigContext); const { prefixCls: customizePrefixCls, diff --git a/components/tree-select/index.tsx b/components/tree-select/index.tsx index 9563ff17acfb..e1df7a9979ad 100644 --- a/components/tree-select/index.tsx +++ b/components/tree-select/index.tsx @@ -256,15 +256,15 @@ const TreeSelectRef = React.forwardRef(InternalTreeSelect) as < type InternalTreeSelectType = typeof TreeSelectRef; -interface TreeSelectInterface extends InternalTreeSelectType { +type CompoundedComponent = InternalTreeSelectType & { TreeNode: typeof TreeNode; SHOW_ALL: typeof SHOW_ALL; SHOW_PARENT: typeof SHOW_PARENT; SHOW_CHILD: typeof SHOW_CHILD; _InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel; -} +}; -const TreeSelect = TreeSelectRef as TreeSelectInterface; +const TreeSelect = TreeSelectRef as CompoundedComponent; // We don't care debug panel /* istanbul ignore next */ diff --git a/components/upload/index.tsx b/components/upload/index.tsx index 67c46049f74b..98a5a8b20095 100644 --- a/components/upload/index.tsx +++ b/components/upload/index.tsx @@ -12,15 +12,15 @@ export type { } from './interface'; type InternalUploadType = typeof InternalUpload; -interface UploadInterface extends InternalUploadType { +type CompoundedComponent = InternalUploadType & { ( props: React.PropsWithChildren> & React.RefAttributes, ): React.ReactElement; Dragger: typeof Dragger; LIST_IGNORE: string; -} +}; -const Upload = InternalUpload as UploadInterface; +const Upload = InternalUpload as CompoundedComponent; Upload.Dragger = Dragger; Upload.LIST_IGNORE = LIST_IGNORE;