Skip to content

Commit 95d4b42

Browse files
committed
🏷️ Improve component types
1 parent 56cd716 commit 95d4b42

File tree

8 files changed

+26
-8
lines changed

8 files changed

+26
-8
lines changed

src/components/Alert/Alert.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ const iconMap = {
1616
alert
1717
}
1818

19+
type ReactAlertProps = {
20+
Element?: keyof JSX.IntrinsicElements
21+
TitleTag?: keyof JSX.IntrinsicElements
22+
children: React.ReactNode
23+
icon?: string
24+
}
25+
1926
const Alert = ({
2027
Element = 'section',
2128
title,
@@ -25,7 +32,7 @@ const Alert = ({
2532
children,
2633
icon,
2734
...rest
28-
}: AlertProps & { icon?: any }) => {
35+
}: AlertProps & ReactAlertProps) => {
2936
const classes = [
3037
'w-alert',
3138
(!icon && !theme) && 'col',

src/components/Alert/alert.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ export type AlertProps = {
99
| 'warning'
1010
| 'alert'
1111
| null
12-
[key: string]: any
1312
}

src/components/Badge/Badge.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import React from 'react'
22
import type { BadgeProps } from './badge'
33
import './badge.scss'
44

5-
const Badge = ({ theme, onClick, children }: BadgeProps) => {
5+
type ReactBadgeProps = {
6+
children: React.ReactNode
7+
} & BadgeProps
8+
9+
const Badge = ({ theme, onClick, children }: ReactBadgeProps) => {
610
const classes = [
711
'w-badge',
812
theme || null,

src/components/Badge/badge.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ export type BadgeProps = {
88
| 'alert'
99
| null
1010
onClick?: () => any
11-
[key: string]: any
1211
}

src/components/Button/Button.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import React from 'react'
22
import type { ButtonProps } from './button'
33
import './button.scss'
44

5+
type ReactButtonProps = {
6+
children: React.ReactNode
7+
}
8+
59
const Button = ({
610
theme,
711
bold,
812
href,
913
children,
1014
onClick,
1115
...rest
12-
}: ButtonProps) => {
16+
}: ButtonProps & ReactButtonProps) => {
1317
const classes = [
1418
'w-button',
1519
bold && 'bold',

src/components/Button/button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export type ButtonProps = {
99
| null
1010
bold?: boolean
1111
href?: string
12+
target?: string
1213
onClick?: () => any
13-
[key: string]: any
1414
}

src/components/Card/Card.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import React from 'react'
22
import type { CardProps } from './card'
33
import './card.scss'
44

5+
type ReactCardProps = {
6+
Element?: keyof JSX.IntrinsicElements
7+
TitleTag?: keyof JSX.IntrinsicElements
8+
children: React.ReactNode
9+
}
10+
511
const Card = ({
612
Element = 'section',
713
title,
@@ -11,7 +17,7 @@ const Card = ({
1117
secondary,
1218
children,
1319
...rest
14-
}: CardProps) => {
20+
}: CardProps & ReactCardProps) => {
1521
const classes = [
1622
'w-card',
1723
className,

src/components/Card/card.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ export type CardProps = {
44
compact?: boolean
55
className?: string
66
secondary?: boolean
7-
[key: string]: any
87
}

0 commit comments

Comments
 (0)