@@ -11,7 +11,7 @@ import Omit from 'omit.js';
11
11
import useConfigInject from '../_util/hooks/useConfigInject' ;
12
12
13
13
export const SwitchSizes = tuple ( 'small' , 'default' ) ;
14
-
14
+ type CheckedType = boolean | string | number ;
15
15
const switchProps = {
16
16
prefixCls : PropTypes . string ,
17
17
size : PropTypes . oneOf ( SwitchSizes ) ,
@@ -21,14 +21,20 @@ const switchProps = {
21
21
tabindex : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
22
22
autofocus : PropTypes . looseBool ,
23
23
loading : PropTypes . looseBool ,
24
- checked : PropTypes . any ,
25
- checkedValue : PropTypes . any . def ( true ) ,
26
- unCheckedValue : PropTypes . any . def ( false ) ,
24
+ checked : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number , PropTypes . looseBool ] ) ,
25
+ checkedValue : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number , PropTypes . looseBool ] ) . def (
26
+ true ,
27
+ ) ,
28
+ unCheckedValue : PropTypes . oneOfType ( [
29
+ PropTypes . string ,
30
+ PropTypes . number ,
31
+ PropTypes . looseBool ,
32
+ ] ) . def ( false ) ,
27
33
onChange : {
28
- type : Function as PropType < ( checked : any , e : Event ) => void > ,
34
+ type : Function as PropType < ( checked : CheckedType , e : Event ) => void > ,
29
35
} ,
30
36
onClick : {
31
- type : Function as PropType < ( checked : any , e : Event ) => void > ,
37
+ type : Function as PropType < ( checked : CheckedType , e : Event ) => void > ,
32
38
} ,
33
39
onKeydown : {
34
40
type : Function as PropType < ( e : Event ) => void > ,
@@ -37,7 +43,7 @@ const switchProps = {
37
43
type : Function as PropType < ( e : Event ) => void > ,
38
44
} ,
39
45
'onUpdate:checked' : {
40
- type : Function as PropType < ( checked : any ) => void > ,
46
+ type : Function as PropType < ( checked : CheckedType ) => void > ,
41
47
} ,
42
48
} ;
43
49
@@ -92,7 +98,7 @@ const Switch = defineComponent({
92
98
} ) ;
93
99
} ) ;
94
100
95
- const setChecked = ( check : any , e : MouseEvent | KeyboardEvent ) => {
101
+ const setChecked = ( check : CheckedType , e : MouseEvent | KeyboardEvent ) => {
96
102
if ( props . disabled ) {
97
103
return ;
98
104
}
0 commit comments