Skip to content

Commit 0babc55

Browse files
fix: badge type
1 parent 9caa5e8 commit 0babc55

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Badge/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { ForwardedRef } from 'react';
22
import BaseBadge from 'react-bootstrap/Badge';
3+
import { ComponentWithAsProp } from '../utils/types/bootstrap';
34

45
const STYLE_VARIANTS = [
56
'primary',
@@ -12,7 +13,7 @@ const STYLE_VARIANTS = [
1213
'dark',
1314
];
1415

15-
interface BadgeProps extends React.HTMLAttributes<HTMLElement> {
16+
interface BadgeProps {
1617
/** Specifies element type for this component */
1718
as?: React.ElementType;
1819
/** Visual style of the badge. The full type definition can be seen [here](https://github.com/openedx/paragon/blob/release-23.x/src/Badge/index.tsx) */
@@ -23,9 +24,9 @@ interface BadgeProps extends React.HTMLAttributes<HTMLElement> {
2324
bsPrefix?: string;
2425
}
2526

26-
const Badge = React.forwardRef(({
27+
const Badge: ComponentWithAsProp<'span', BadgeProps> = React.forwardRef(({
2728
as = 'span', variant = 'primary', pill = false, bsPrefix = 'badge', ...props
28-
}: BadgeProps, ref: ForwardedRef<HTMLElement>) => (
29+
}: BadgeProps, ref: ForwardedRef<HTMLSpanElement>) => (
2930
<BaseBadge as={as} variant={variant} pill={pill} bsPrefix={bsPrefix} {...props} ref={ref} />
3031
));
3132

0 commit comments

Comments
 (0)