Skip to content

Commit 6cfe28f

Browse files
committed
fix(ts): hack varying label props into working with ts
1 parent fcf7659 commit 6cfe28f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

components/forms/Label.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ import cx from 'classnames';
44
import styles from './label.module.scss';
55
import { Text } from 'components/Typography/Text';
66

7-
interface OwnProps {
7+
type ElementProps = HTMLProps<HTMLLIElement>;
8+
9+
type Props = ElementProps & {
810
label: string;
911
description?: string;
10-
as?: keyof JSX.IntrinsicElements;
11-
}
12-
13-
type Props = HTMLProps<HTMLLabelElement> & OwnProps;
12+
as?: string;
13+
};
1414

15-
export const Label: FC<Props> = ({ as: Element = 'label', className, label, description, children, ...props }) => {
15+
export const Label: FC<Props> = ({ as: Element = 'label', className, label, description, children, ...rest }) => {
16+
// just a hack to not trip of typescript with the props of the `as` element.
17+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
18+
const props = rest as any;
1619
return (
1720
<Element className={cx(styles.label, className)} {...props}>
1821
<Text>{label}</Text>

0 commit comments

Comments
 (0)