Skip to content

Commit

Permalink
Fix #2974: Badge/Avatar typescript inheritance (#2975)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Jun 10, 2022
1 parent a8b2085 commit d838b83
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions components/lib/avatar/Avatar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ type AvatarShapeType = 'square' | 'circle';

type AvatarTemplateType = React.ReactNode | ((props: AvatarProps) => React.ReactNode);

export interface AvatarProps {
export interface AvatarProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref'> {

This comment has been minimized.

Copy link
@inad9300

inad9300 Jun 14, 2022

Contributor

The React.InputHTMLAttributes part seems to refer to the attributes of <input>, which would be incorrect here. I would use instead the parent interface React.HTMLAttributes.

The same applies to BadgeProps below.

label?: string;
icon?: IconType<AvatarProps>;
image?: string;
size?: AvatarSizeType;
shape?: AvatarShapeType;
style?: object;
className?: string;
template?: AvatarTemplateType;
imageAlt?: string;
onImageError?(event: React.SyntheticEvent): void;
Expand Down
4 changes: 1 addition & 3 deletions components/lib/badge/Badge.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ type BadgeSeverityType = 'success' | 'info' | 'warn' | 'error' | (string & {});

type BadgeSizeType = 'normal' | 'large' | 'xlarge';

export interface BadgeProps {
export interface BadgeProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, 'ref'> {
value?: any;
severity?: BadgeSeverityType;
size?: BadgeSizeType;
style?: object;
className?: string;
children?: React.ReactNode;
}

Expand Down

3 comments on commit d838b83

@inad9300
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a good opportunity to consider other interfaces not currently extending from React types, such as Card and Chip.

@melloware
Copy link
Member Author

@melloware melloware commented on d838b83 Jun 14, 2022 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inad9300
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I'll be able to, sorry.

Please sign in to comment.