diff --git a/packages/varlet-ui/src/button/props.ts b/packages/varlet-ui/src/button/props.ts index 7b2ec319485..68c375bab7d 100644 --- a/packages/varlet-ui/src/button/props.ts +++ b/packages/varlet-ui/src/button/props.ts @@ -12,12 +12,12 @@ function sizeValidator(size: string): boolean { export const props = { type: { - type: String, + type: String as PropType<'default' | 'primary' | 'info' | 'success' | 'warning' | 'danger'>, default: 'default', validator: typeValidator, }, size: { - type: String, + type: String as PropType<'normal' | 'mini' | 'small' | 'large'>, default: 'normal', validator: sizeValidator, }, diff --git a/packages/varlet-ui/src/checkbox-group/props.ts b/packages/varlet-ui/src/checkbox-group/props.ts index 63b3d168805..dd4a1931f11 100644 --- a/packages/varlet-ui/src/checkbox-group/props.ts +++ b/packages/varlet-ui/src/checkbox-group/props.ts @@ -15,7 +15,7 @@ export const props = { type: [String, Number], }, direction: { - type: String, + type: String as PropType<'horizontal' | 'vertical'>, default: 'horizontal', }, validateTrigger: { diff --git a/packages/varlet-ui/src/dialog/props.ts b/packages/varlet-ui/src/dialog/props.ts index 7fc7feb2cd1..5f513eb130b 100644 --- a/packages/varlet-ui/src/dialog/props.ts +++ b/packages/varlet-ui/src/dialog/props.ts @@ -19,7 +19,7 @@ export const props = { type: String, }, messageAlign: { - type: String, + type: String as PropType<'left' | 'center' | 'right'>, default: 'left', validator: messageAlignValidator, }, diff --git a/packages/varlet-ui/src/image/props.ts b/packages/varlet-ui/src/image/props.ts index fff8a7a99c0..4df3ef30547 100644 --- a/packages/varlet-ui/src/image/props.ts +++ b/packages/varlet-ui/src/image/props.ts @@ -9,7 +9,7 @@ export const props = { type: String, }, fit: { - type: String, + type: String as PropType<'fill' | 'contain' | 'cover' | 'none' | 'scale-down'>, validator: fitValidator, default: 'fill', }, @@ -34,7 +34,7 @@ export const props = { }, lazy: { type: Boolean, - default: false + default: false, }, ripple: { type: Boolean, diff --git a/packages/varlet-ui/src/input/props.ts b/packages/varlet-ui/src/input/props.ts index edd226af5d0..4f561be7849 100644 --- a/packages/varlet-ui/src/input/props.ts +++ b/packages/varlet-ui/src/input/props.ts @@ -11,7 +11,7 @@ export const props = { type: [String, Number], }, type: { - type: String, + type: String as PropType<'text' | 'password'>, default: 'text', validator: typeValidator, }, diff --git a/packages/varlet-ui/src/menu/props.ts b/packages/varlet-ui/src/menu/props.ts index 1391a2107b7..396dd0fd7ce 100644 --- a/packages/varlet-ui/src/menu/props.ts +++ b/packages/varlet-ui/src/menu/props.ts @@ -10,7 +10,7 @@ export const props = { default: false, }, alignment: { - type: String, + type: String as PropType<'top' | 'bottom'>, default: 'top', validator: alignmentValidator, }, diff --git a/packages/varlet-ui/src/popup/props.ts b/packages/varlet-ui/src/popup/props.ts index 0a3d6edb222..7a004725665 100644 --- a/packages/varlet-ui/src/popup/props.ts +++ b/packages/varlet-ui/src/popup/props.ts @@ -10,7 +10,7 @@ export const props = { default: false, }, position: { - type: String, + type: String as PropType<'top' | 'bottom' | 'right' | 'left' | 'center'>, default: 'center', validator: positionValidator, }, diff --git a/packages/varlet-ui/src/radio-group/props.ts b/packages/varlet-ui/src/radio-group/props.ts index df7a44dfeab..92946de0668 100644 --- a/packages/varlet-ui/src/radio-group/props.ts +++ b/packages/varlet-ui/src/radio-group/props.ts @@ -11,7 +11,7 @@ export const props = { default: undefined, }, direction: { - type: String, + type: String as PropType<'horizontal' | 'vertical'>, default: 'horizontal', }, validateTrigger: { diff --git a/packages/varlet-ui/src/row/props.ts b/packages/varlet-ui/src/row/props.ts index 3d812633de2..c9994efbb07 100644 --- a/packages/varlet-ui/src/row/props.ts +++ b/packages/varlet-ui/src/row/props.ts @@ -1,35 +1,29 @@ import { PropType } from 'vue' function justifyValidator(justify: string) { - return [ - 'flex-start', - 'flex-end', - 'center', - 'space-between', - 'space-around' - ].includes(justify) + return ['flex-start', 'flex-end', 'center', 'space-between', 'space-around'].includes(justify) } function alignValidator(align: string) { - return ['flex-start', 'flex-center', 'flex-end'].includes(align) + return ['flex-start', 'center', 'flex-end'].includes(align) } export const props = { gutter: { type: [String, Number], - default: 0 + default: 0, }, justify: { - type: String, + type: String as PropType<'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around'>, default: 'flex-start', - validator: justifyValidator + validator: justifyValidator, }, align: { - type: String, + type: String as PropType<'flex-start' | 'center' | 'flex-end'>, default: 'flex-start', - validator: alignValidator + validator: alignValidator, }, onClick: { - type: Function as PropType<(e: Event) => void> - } + type: Function as PropType<(e: Event) => void>, + }, } diff --git a/packages/varlet-ui/src/select/props.ts b/packages/varlet-ui/src/select/props.ts index 340cc32e690..88b4701a317 100644 --- a/packages/varlet-ui/src/select/props.ts +++ b/packages/varlet-ui/src/select/props.ts @@ -55,7 +55,7 @@ export const props = { default: ',', }, textAlign: { - type: String, + type: String as PropType<'left' | 'right' | 'center'>, default: 'left', validator: textAlignValidator, }, diff --git a/packages/varlet-ui/src/tabs/props.ts b/packages/varlet-ui/src/tabs/props.ts index c835ea9fc3e..2a24e75b10d 100644 --- a/packages/varlet-ui/src/tabs/props.ts +++ b/packages/varlet-ui/src/tabs/props.ts @@ -12,12 +12,12 @@ export const props = { default: 0, }, layoutDirection: { - type: String, + type: String as PropType<'horizontal' | 'vertical'>, default: 'horizontal', validator: directionValidator, }, itemDirection: { - type: String, + type: String as PropType<'horizontal' | 'vertical'>, default: 'horizontal', validator: directionValidator, }, diff --git a/packages/varlet-ui/types/row.d.ts b/packages/varlet-ui/types/row.d.ts index 30d9ef084e8..a8968b90473 100644 --- a/packages/varlet-ui/types/row.d.ts +++ b/packages/varlet-ui/types/row.d.ts @@ -3,7 +3,7 @@ import { VarComponent } from './varComponent' interface RowProps { gutter?: string | number justify?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' - align?: 'flex-start' | 'flex-center' | 'flex-end' + align?: 'flex-start' | 'center' | 'flex-end' onClick?: (e: Event) => void }