diff --git a/components/badge/index.tsx b/components/badge/index.tsx index 7154ff63823a..9bae21b51dd5 100644 --- a/components/badge/index.tsx +++ b/components/badge/index.tsx @@ -13,9 +13,9 @@ import { isPresetColor } from './utils'; export type { ScrollNumberProps } from './ScrollNumber'; -interface CompoundedComponent extends React.FC { +type CompoundedComponent = React.FC & { Ribbon: typeof Ribbon; -} +}; export interface BadgeProps { /** Number to show in badge */ @@ -137,7 +137,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 04a5bbd78551..c8936c87d408 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -58,7 +58,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) { @@ -73,7 +73,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), ); } @@ -131,12 +131,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 955e1b382eb6..1b55677fe777 100644 --- a/components/checkbox/index.tsx +++ b/components/checkbox/index.tsx @@ -6,12 +6,13 @@ import Group from './Group'; export type { CheckboxChangeEvent, CheckboxProps } from './Checkbox'; export type { 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 7a601197f9fa..f4d742eec21e 100644 --- a/components/input/index.tsx +++ b/components/input/index.tsx @@ -12,13 +12,14 @@ export type { PasswordProps } from './Password'; export type { SearchProps } from './Search'; export type { 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 cd07b1a2ab38..82c17264a3ec 100644 --- a/components/mentions/index.tsx +++ b/components/mentions/index.tsx @@ -53,12 +53,13 @@ interface MentionsEntity { value: string; } -interface CompoundedComponent - extends React.ForwardRefExoticComponent> { +type CompoundedComponent = React.ForwardRefExoticComponent< + MentionProps & React.RefAttributes +> & { Option: typeof Option; _InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel; getMentions: (value: string, config?: MentionsConfig) => MentionsEntity[]; -} +}; const InternalMentions: React.ForwardRefRenderFunction = ( { @@ -203,7 +204,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/menu/index.tsx b/components/menu/index.tsx index 5c75a6591540..3381d96fa57b 100644 --- a/components/menu/index.tsx +++ b/components/menu/index.tsx @@ -19,20 +19,21 @@ export type MenuRef = { focus: (options?: FocusOptions) => void; }; -interface CompoundedComponent - extends React.ForwardRefExoticComponent> { +type CompoundedComponent = React.ForwardRefExoticComponent< + MenuProps & React.RefAttributes +> & { Divider: typeof MenuDivider; Item: typeof Item; SubMenu: typeof SubMenu; ItemGroup: typeof ItemGroup; -} +}; const Menu = forwardRef((props, ref) => { const menuRef = useRef(null); const context = React.useContext(SiderContext); useImperativeHandle(ref, () => ({ - focus: options => { + focus: (options) => { menuRef.current?.focus(options); }, menu: menuRef.current, 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 d60c762e718c..cd3acf4486ca 100644 --- a/components/skeleton/Skeleton.tsx +++ b/components/skeleton/Skeleton.tsx @@ -77,15 +77,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 a9a611bd2da7..ec81d877854e 100644 --- a/components/space/index.tsx +++ b/components/space/index.tsx @@ -40,7 +40,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 { @@ -60,7 +60,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], @@ -151,9 +151,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 c6b4d789228c..4db89dc91fa4 100755 --- a/components/switch/index.tsx +++ b/components/switch/index.tsx @@ -37,11 +37,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( (