diff --git a/components/badge/index.tsx b/components/badge/index.tsx index 830b174281af..beba79af27a3 100644 --- a/components/badge/index.tsx +++ b/components/badge/index.tsx @@ -12,9 +12,9 @@ import { isPresetColor } from './utils'; export { ScrollNumberProps } from './ScrollNumber'; -interface CompoundedComponent extends React.FC { +type CompoundedComponent = React.FC & { Ribbon: typeof Ribbon; -} +}; export interface BadgeProps { /** Number to show in badge */ @@ -133,7 +133,7 @@ const Badge: CompoundedComponent = ({ const displayNode = !livingCount || typeof livingCount !== 'object' ? undefined - : cloneElement(livingCount, oriProps => ({ + : cloneElement(livingCount, (oriProps) => ({ style: { ...mergedStyle, ...oriProps.style, diff --git a/components/button/button.tsx b/components/button/button.tsx index c6be75051395..6e3747bef6cf 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -55,7 +55,7 @@ function insertSpace(child: React.ReactElement | string | number, needInserted: function spaceChildren(children: React.ReactNode, needInserted: boolean) { let isPrevChildPure: boolean = false; const childList: React.ReactNode[] = []; - React.Children.forEach(children, child => { + React.Children.forEach(children, (child) => { const type = typeof child; const isCurrentChildPure = type === 'string' || type === 'number'; if (isPrevChildPure && isCurrentChildPure) { @@ -70,7 +70,7 @@ function spaceChildren(children: React.ReactNode, needInserted: boolean) { }); // Pass to React.Children.map to auto fill key - return React.Children.map(childList, child => + return React.Children.map(childList, (child) => insertSpace(child as React.ReactElement | string | number, needInserted), ); } @@ -128,12 +128,13 @@ export type NativeButtonProps = { export type ButtonProps = Partial; -interface CompoundedComponent - extends React.ForwardRefExoticComponent> { +type CompoundedComponent = React.ForwardRefExoticComponent< + ButtonProps & React.RefAttributes +> & { Group: typeof Group; /** @internal */ __ANT_BUTTON: boolean; -} +}; type Loading = number | boolean; diff --git a/components/checkbox/index.tsx b/components/checkbox/index.tsx index f746238fac12..660112a8cc85 100644 --- a/components/checkbox/index.tsx +++ b/components/checkbox/index.tsx @@ -6,12 +6,13 @@ import Group from './Group'; export { CheckboxChangeEvent, CheckboxProps } from './Checkbox'; export { CheckboxGroupProps, CheckboxOptionType } from './Group'; -interface CompoundedComponent - extends React.ForwardRefExoticComponent> { +type CompoundedComponent = React.ForwardRefExoticComponent< + CheckboxProps & React.RefAttributes +> & { Group: typeof Group; /** @internal */ __ANT_CHECKBOX: boolean; -} +}; const Checkbox = InternalCheckbox as CompoundedComponent; diff --git a/components/input/index.tsx b/components/input/index.tsx index 0516be61ab51..2b56a3e96149 100644 --- a/components/input/index.tsx +++ b/components/input/index.tsx @@ -12,13 +12,14 @@ export { PasswordProps } from './Password'; export { SearchProps } from './Search'; export { TextAreaProps } from './TextArea'; -interface CompoundedComponent - extends React.ForwardRefExoticComponent> { +type CompoundedComponent = React.ForwardRefExoticComponent< + InputProps & React.RefAttributes +> & { Group: typeof Group; Search: typeof Search; TextArea: typeof TextArea; Password: typeof Password; -} +}; const Input = InternalInput as CompoundedComponent; diff --git a/components/mentions/index.tsx b/components/mentions/index.tsx index 9558e41af1ec..47fc2518586f 100644 --- a/components/mentions/index.tsx +++ b/components/mentions/index.tsx @@ -48,11 +48,12 @@ interface MentionsEntity { value: string; } -interface CompoundedComponent - extends React.ForwardRefExoticComponent> { +type CompoundedComponent = React.ForwardRefExoticComponent< + MentionProps & React.RefAttributes +> & { Option: typeof Option; getMentions: (value: string, config?: MentionsConfig) => MentionsEntity[]; -} +}; const InternalMentions: React.ForwardRefRenderFunction = ( { @@ -185,7 +186,7 @@ Mentions.getMentions = (value: string = '', config: MentionsConfig = {}): Mentio .map((str = ''): MentionsEntity | null => { let hitPrefix: string | null = null; - prefixList.some(prefixStr => { + prefixList.some((prefixStr) => { const startStr = str.slice(0, prefixStr.length); if (startStr === prefixStr) { hitPrefix = prefixStr; diff --git a/components/radio/index.tsx b/components/radio/index.tsx index 4bd53ad6361f..bae4f15edeac 100644 --- a/components/radio/index.tsx +++ b/components/radio/index.tsx @@ -14,13 +14,15 @@ export { RadioProps, } from './interface'; export { Button, Group }; -interface CompoundedComponent - extends React.ForwardRefExoticComponent> { + +type CompoundedComponent = React.ForwardRefExoticComponent< + RadioProps & React.RefAttributes +> & { Group: typeof Group; Button: typeof Button; /** @internal */ __ANT_RADIO: boolean; -} +}; const Radio = InternalRadio as CompoundedComponent; Radio.Button = Button; diff --git a/components/skeleton/Skeleton.tsx b/components/skeleton/Skeleton.tsx index 2c3f5315fb8e..47d68a424d2d 100644 --- a/components/skeleton/Skeleton.tsx +++ b/components/skeleton/Skeleton.tsx @@ -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 & CompoundedComponent = props => { +const Skeleton: React.FC & CompoundedComponent = (props) => { const { prefixCls: customizePrefixCls, loading, diff --git a/components/space/index.tsx b/components/space/index.tsx index a09c08de251b..d69cb5b4e8b4 100644 --- a/components/space/index.tsx +++ b/components/space/index.tsx @@ -38,7 +38,7 @@ function getNumberSize(size: SpaceSize) { return typeof size === 'string' ? spaceSize[size] : size || 0; } -const Space: React.FC = props => { +const Space: React.FC = (props) => { const { getPrefixCls, space, direction: directionConfig } = React.useContext(ConfigContext); const { @@ -58,7 +58,7 @@ const Space: React.FC = props => { const [horizontalSize, verticalSize] = React.useMemo( () => - ((Array.isArray(size) ? size : [size, size]) as [SpaceSize, SpaceSize]).map(item => + ((Array.isArray(size) ? size : [size, size]) as [SpaceSize, SpaceSize]).map((item) => getNumberSize(item), ), [size], @@ -146,9 +146,9 @@ const Space: React.FC = props => { ); }; -interface CompoundedComponent extends React.FC { +type CompoundedComponent = React.FC & { Compact: typeof Compact; -} +}; const CompoundedSpace = Space as CompoundedComponent; CompoundedSpace.Compact = Compact; diff --git a/components/switch/index.tsx b/components/switch/index.tsx index cb5280822a0a..9c4e6d7382fa 100755 --- a/components/switch/index.tsx +++ b/components/switch/index.tsx @@ -35,11 +35,12 @@ export interface SwitchProps { id?: string; } -interface CompoundedComponent - extends React.ForwardRefExoticComponent> { +type CompoundedComponent = React.ForwardRefExoticComponent< + SwitchProps & React.RefAttributes +> & { /** @internal */ __ANT_SWITCH: boolean; -} +}; const Switch = React.forwardRef( ( diff --git a/components/tree/index.tsx b/components/tree/index.tsx index e1c161372115..32c2f8e9142a 100644 --- a/components/tree/index.tsx +++ b/components/tree/index.tsx @@ -5,9 +5,9 @@ import type { DataNode } from 'rc-tree/lib/interface'; import type { TreeProps } from './Tree'; import TreePure from './Tree'; -import DirectoryTree from './DirectoryTree' +import DirectoryTree from './DirectoryTree'; -export { DataNode } +export { DataNode }; export { EventDataNode } from 'rc-tree/lib/interface'; export { DirectoryTreeProps, ExpandAction as DirectoryTreeExpandAction } from './DirectoryTree'; export { @@ -21,7 +21,6 @@ export { TreeProps, } from './Tree'; - type CompoundedComponent = (( props: React.PropsWithChildren> & { ref?: React.Ref }, ) => React.ReactElement) & { @@ -29,8 +28,8 @@ type CompoundedComponent = (( DirectoryTree: typeof DirectoryTree; }; -const Tree = TreePure as unknown as CompoundedComponent -Tree.DirectoryTree = DirectoryTree -Tree.TreeNode = TreeNode +const Tree = TreePure as unknown as CompoundedComponent; +Tree.DirectoryTree = DirectoryTree; +Tree.TreeNode = TreeNode; -export default Tree; \ No newline at end of file +export default Tree;