Skip to content

Commit

Permalink
fix(types): external module type error (CompoundedComponent)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcch committed Nov 19, 2022
1 parent 77ea403 commit 5cf65f3
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 27 deletions.
4 changes: 2 additions & 2 deletions components/badge/index.tsx
Expand Up @@ -13,9 +13,9 @@ import { isPresetColor } from './utils';

export type { 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
7 changes: 4 additions & 3 deletions components/button/button.tsx
Expand Up @@ -131,12 +131,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 type { CheckboxChangeEvent, CheckboxProps } from './Checkbox';
export type { 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
7 changes: 4 additions & 3 deletions components/input/index.tsx
Expand Up @@ -12,13 +12,14 @@ export type { PasswordProps } from './Password';
export type { SearchProps } from './Search';
export type { 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
7 changes: 4 additions & 3 deletions components/mentions/index.tsx
Expand Up @@ -53,12 +53,13 @@ interface MentionsEntity {
value: string;
}

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

const InternalMentions: React.ForwardRefRenderFunction<MentionsRef, MentionProps> = (
{
Expand Down
7 changes: 4 additions & 3 deletions components/menu/index.tsx
Expand Up @@ -19,13 +19,14 @@ export type MenuRef = {
focus: (options?: FocusOptions) => void;
};

interface CompoundedComponent
extends React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<MenuRef>> {
type CompoundedComponent = React.ForwardRefExoticComponent<
MenuProps & React.RefAttributes<MenuRef>
> & {
Divider: typeof MenuDivider;
Item: typeof Item;
SubMenu: typeof SubMenu;
ItemGroup: typeof ItemGroup;
}
};

const Menu = forwardRef<MenuRef, MenuProps>((props, ref) => {
const menuRef = useRef<RcMenuRef>(null);
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
4 changes: 2 additions & 2 deletions components/skeleton/Skeleton.tsx
Expand Up @@ -77,13 +77,13 @@ 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 {
Expand Down
4 changes: 2 additions & 2 deletions components/space/index.tsx
Expand Up @@ -151,9 +151,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
7 changes: 4 additions & 3 deletions components/switch/index.tsx
Expand Up @@ -37,11 +37,12 @@ export interface SwitchProps {
id?: string;
}

interface CompoundedComponent
extends React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLElement>> {
type CompoundedComponent = React.ForwardRefExoticComponent<
SwitchProps & React.RefAttributes<HTMLElement>
> & {
/** @internal */
__ANT_SWITCH: boolean;
}
};

const Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(
(
Expand Down

0 comments on commit 5cf65f3

Please sign in to comment.