Skip to content

Commit

Permalink
fix(radio): fix warning when prop value type is boolean, close tusen-…
Browse files Browse the repository at this point in the history
  • Loading branch information
jizai1125 committed Aug 18, 2022
1 parent 9055caa commit 8fddb04
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/radio/src/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useRtl } from '../../_mixins/use-rtl'

function mapSlot (
defaultSlot: VNode[],
value: string | number | null,
value: string | number | boolean | null,
clsPrefix: string
): {
children: VNodeChild[]
Expand Down Expand Up @@ -100,9 +100,13 @@ function mapSlot (
export const radioGroupProps = {
...(useTheme.props as ThemeProps<RadioTheme>),
name: String,
value: [String, Number] as PropType<string | number | null>,
value: [String, Number, Boolean] as PropType<
string | number | boolean | null
>,
defaultValue: {
type: [String, Number] as PropType<string | number | null>,
type: [String, Number, Boolean] as PropType<
string | number | boolean | null
>,
default: null
},
size: String as PropType<'small' | 'medium' | 'large'>,
Expand Down Expand Up @@ -145,7 +149,7 @@ export default defineComponent({
controlledValueRef,
uncontrolledValueRef
)
function doUpdateValue (value: string | number): void {
function doUpdateValue (value: string | number | boolean): void {
const { onUpdateValue, 'onUpdate:value': _onUpdateValue } = props
if (onUpdateValue) {
call(onUpdateValue as OnUpdateValueImpl, value)
Expand Down
2 changes: 1 addition & 1 deletion src/radio/src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type OnUpdateValue = (value: string & number) => void

export type OnUpdateValueImpl = (value: string | number) => void
export type OnUpdateValueImpl = (value: string | number | boolean) => void
4 changes: 2 additions & 2 deletions src/radio/src/use-radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { OnUpdateValue, OnUpdateValueImpl } from './interface'
const radioProps = {
name: String,
value: {
type: [String, Number] as PropType<string | number>,
type: [String, Number, Boolean] as PropType<string | number | boolean>,
default: 'on'
},
checked: {
Expand Down Expand Up @@ -53,7 +53,7 @@ const radioProps = {
export interface RadioGroupInjection {
mergedClsPrefixRef: Ref<string>
nameRef: Ref<string | undefined>
valueRef: Ref<string | number | null>
valueRef: Ref<string | number | boolean | null>
mergedSizeRef: Ref<'small' | 'medium' | 'large'>
disabledRef: Ref<boolean>
doUpdateValue: OnUpdateValue
Expand Down

0 comments on commit 8fddb04

Please sign in to comment.