1- <script setup>
1+ <script lang="ts" setup>
22import { useClipboard } from ' @vueuse/core'
33
44const pkg = useState (' badge-pkg' , () => ' nuxt' )
5- const type = useState (' badge-type' , () => ' version' )
5+ const type = useState < BadgeType > (' badge-type' , () => ' version' )
66const isValid = ref (true )
77
88const { copy, copied } = useClipboard ({ copiedDuring: 2000 })
@@ -16,7 +16,7 @@ const badgeStyle = useState('badge-style', () => 'default')
1616
1717const styles = [' default' , ' shieldsio' ]
1818
19- const validateHex = hex => {
19+ const validateHex = ( hex : string ) => {
2020 if (! hex ) return true
2121 const clean = hex .replace (' #' , ' ' )
2222 return / ^ [0-9A-F ] {3} $ / i .test (clean ) || / ^ [0-9A-F ] {6} $ / i .test (clean )
@@ -28,7 +28,7 @@ const isInputValid = computed(
2828 () => isLabelHexValid .value && isBadgeHexValid .value && pkg .value .length > 0 ,
2929)
3030
31- const cleanHex = hex => hex? .replace (' #' , ' ' ) || ' '
31+ const cleanHex = ( hex : string ) => hex ?.replace (' #' , ' ' ) || ' '
3232
3333const queryParams = computed (() => {
3434 if (! isInputValid .value ) return ' '
@@ -58,7 +58,7 @@ watch([pkg, type, queryParams], () => {
5858 isValid .value = true
5959})
6060
61- const formatLabel = str => {
61+ const formatLabel = ( str : string ) => {
6262 if (! str || typeof str !== ' string' ) return ' '
6363 return str
6464 .split (' -' )
0 commit comments