Skip to content

Commit 3d5e10c

Browse files
committed
♻️ Improve TS types
1 parent 983ad0e commit 3d5e10c

File tree

25 files changed

+95
-110
lines changed

25 files changed

+95
-110
lines changed

src/blocks/Button/Button.astro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { classNames } from 'webcoreui'
33
import {
44
Badge,
55
Button as WebcoreButton,
6-
Icon,
7-
type IconProps
6+
Icon
87
} from 'webcoreui/astro'
98
109
import type { ButtonProps } from './button'
@@ -28,7 +27,7 @@ const Component = badge ? Badge : WebcoreButton
2827
<Fragment>
2928
{icon.startsWith('<svg')
3029
? <Fragment set:html={icon} />
31-
: <Icon type={icon as IconProps['type']} />
30+
: <Icon type={icon} />
3231
}
3332
</Fragment>
3433
)}

src/blocks/ErrorPage/ErrorPage.astro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
import {
33
Button,
4-
Icon,
5-
type IconProps
4+
Icon
65
} from 'webcoreui/astro'
76
87
import type { ErrorPageProps } from './errorPage'
@@ -36,7 +35,7 @@ const typeStyle = typeColor
3635
<Fragment>
3736
{button.icon.startsWith('<svg')
3837
? <Fragment set:html={button.icon} />
39-
: <Icon type={button.icon as IconProps['type']} />
38+
: <Icon type={button.icon} />
4039
}
4140
</Fragment>
4241
)}

src/blocks/GridWithIcons/GridWithIcons.astro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ interface Props extends GridWithIconsProps {}
66
77
import {
88
ConditionalWrapper,
9-
Icon,
10-
type IconProps
9+
Icon
1110
} from 'webcoreui/astro'
1211
1312
const {
@@ -47,7 +46,7 @@ const wrapperClasses = [
4746
<Fragment>
4847
{item.icon.startsWith('<svg')
4948
? <Fragment set:html={item.icon} />
50-
: <Icon type={item.icon as IconProps['type']} />
49+
: <Icon type={item.icon} />
5150
}
5251
</Fragment>
5352
)}

src/blocks/Hero/Hero.astro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import {
33
Badge,
44
Button,
55
ConditionalWrapper,
6-
Icon,
7-
type IconProps
6+
Icon
87
} from 'webcoreui/astro'
98
109
import AvatarWithRating from '@blocks/AvatarWithRating/AvatarWithRating.astro'
@@ -52,7 +51,7 @@ const classes = [
5251
<Fragment>
5352
{button.icon.startsWith('<svg')
5453
? <Fragment set:html={button.icon} />
55-
: <Icon type={button.icon as IconProps['type']} />
54+
: <Icon type={button.icon} />
5655
}
5756
</Fragment>
5857
)}

src/blocks/IconList/IconList.astro

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import styles from './icon-list.module.scss'
44
55
interface Props extends IconListProps {}
66
7-
import {
8-
Icon,
9-
type IconProps
10-
} from 'webcoreui/astro'
7+
import { Icon } from 'webcoreui/astro'
118
129
const {
1310
items,
@@ -38,7 +35,7 @@ const styleVariables = [
3835
<li style={getColor(item.color)}>
3936
{item.icon.startsWith('<svg')
4037
? <Fragment set:html={item.icon} />
41-
: <Icon type={item.icon as IconProps['type']} />
38+
: <Icon type={item.icon} />
4239
}
4340
<div set:html={item.text} />
4441
</li>

src/blocks/Profile/Profile.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import {
33
Avatar,
44
Badge,
5+
type BadgeProps,
56
Card,
67
Table,
78
Tabs
@@ -18,8 +19,8 @@ const tabItems = [{
1819
value: 'contact'
1920
}]
2021
21-
const tasks = [
22-
{ theme: null, label: 'IP', ticket: 'W4567 - Home redesign' },
22+
const tasks: BadgeProps[] = [
23+
{ theme: undefined, label: 'IP', ticket: 'W4567 - Home redesign' },
2324
{ theme: 'alert', label: 'P1', ticket: 'W2345 - Payment gateway warnings' },
2425
{ theme: 'warning', label: 'P3', ticket: 'W6789 - Investigate user auth issues' },
2526
{ theme: 'info', label: 'TODO', ticket: 'W1357 - Mobile redesign' }
@@ -45,7 +46,7 @@ const tasks = [
4546
<div class="flex column xs">
4647
{tasks.map(task => (
4748
<div>
48-
<Badge theme={task.theme as any}>
49+
<Badge theme={task.theme}>
4950
{task.label}
5051
</Badge>
5152
<a href="#" class:list={['muted', styles.task]}>

src/blocks/Profile/Profile.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import {
33
Avatar,
44
Badge,
5+
type BadgeProps,
56
Card,
67
Table,
78
Tabs
@@ -18,8 +19,8 @@ const tabItems = [{
1819
value: 'contact'
1920
}]
2021

21-
const tasks = [
22-
{ theme: null, label: 'IP', ticket: 'W4567 - Home redesign' },
22+
const tasks: BadgeProps[] = [
23+
{ theme: undefined, label: 'IP', ticket: 'W4567 - Home redesign' },
2324
{ theme: 'alert', label: 'P1', ticket: 'W2345 - Payment gateway warnings' },
2425
{ theme: 'warning', label: 'P3', ticket: 'W6789 - Investigate user auth issues' },
2526
{ theme: 'info', label: 'TODO', ticket: 'W1357 - Mobile redesign' }
@@ -47,7 +48,7 @@ const Profile = () => {
4748
<div className="flex column xs">
4849
{tasks.map((task, index) => (
4950
<div key={index} className="flex xs items-center">
50-
<Badge theme={task.theme as any}>
51+
<Badge theme={task.theme}>
5152
{task.label}
5253
</Badge>
5354
<a href="#" className={['muted', styles.task].join(' ')}>

src/blocks/Tiles/Tiles.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { Button, Card, Icon, type IconProps } from 'webcoreui/astro'
2+
import { Button, Card, Icon } from 'webcoreui/astro'
33
44
import type { TilesProps } from './tiles'
55
import styles from './tiles.module.scss'
@@ -25,7 +25,7 @@ const {
2525
<Fragment>
2626
{item.icon.startsWith('<svg')
2727
? <Fragment set:html={item.icon} />
28-
: <Icon type={item.icon as IconProps['type']} />
28+
: <Icon type={item.icon} />
2929
}
3030
</Fragment>
3131
)}

src/components/BottomNavigation/BottomNavigation.astro

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import Icon from '../Icon/Icon.astro'
55
66
import styles from './bottomnavigation.module.scss'
77
8-
import type { IconProps } from '../Icon/icon'
9-
108
interface Props extends BottomNavigationProps {}
119
1210
const {
@@ -39,7 +37,7 @@ const styleVariable = maxWidth
3937
<Fragment>
4038
{item.icon?.startsWith('<svg')
4139
? <Fragment set:html={item.icon} />
42-
: <Icon type={item.icon as IconProps['type']} />
40+
: <Icon type={item.icon} />
4341
}
4442
</Fragment>
4543
)}

src/components/Breadcrumb/Breadcrumb.astro

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import Icon from '../Icon/Icon.astro'
66
77
import styles from './breadcrumb.module.scss'
88
9-
import type { IconProps } from '../Icon/icon'
10-
119
interface Props extends BreadcrumbProps {}
1210
1311
const {
@@ -33,7 +31,7 @@ const classes = [
3331
<Fragment>
3432
{item.icon.startsWith('<svg')
3533
? <Fragment set:html={item.icon} />
36-
: <Icon type={item.icon as IconProps['type']} />
34+
: <Icon type={item.icon} />
3735
}
3836
</Fragment>
3937
)}

0 commit comments

Comments
 (0)