@@ -11,7 +11,7 @@ import Omit from 'omit.js';
1111import useConfigInject from '../_util/hooks/useConfigInject' ;
1212
1313export const SwitchSizes = tuple ( 'small' , 'default' ) ;
14-
14+ type CheckedType = boolean | string | number ;
1515const switchProps = {
1616 prefixCls : PropTypes . string ,
1717 size : PropTypes . oneOf ( SwitchSizes ) ,
@@ -21,14 +21,20 @@ const switchProps = {
2121 tabindex : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) ,
2222 autofocus : PropTypes . looseBool ,
2323 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 ) ,
2733 onChange : {
28- type : Function as PropType < ( checked : any , e : Event ) => void > ,
34+ type : Function as PropType < ( checked : CheckedType , e : Event ) => void > ,
2935 } ,
3036 onClick : {
31- type : Function as PropType < ( checked : any , e : Event ) => void > ,
37+ type : Function as PropType < ( checked : CheckedType , e : Event ) => void > ,
3238 } ,
3339 onKeydown : {
3440 type : Function as PropType < ( e : Event ) => void > ,
@@ -37,7 +43,7 @@ const switchProps = {
3743 type : Function as PropType < ( e : Event ) => void > ,
3844 } ,
3945 'onUpdate:checked' : {
40- type : Function as PropType < ( checked : any ) => void > ,
46+ type : Function as PropType < ( checked : CheckedType ) => void > ,
4147 } ,
4248} ;
4349
@@ -92,7 +98,7 @@ const Switch = defineComponent({
9298 } ) ;
9399 } ) ;
94100
95- const setChecked = ( check : any , e : MouseEvent | KeyboardEvent ) => {
101+ const setChecked = ( check : CheckedType , e : MouseEvent | KeyboardEvent ) => {
96102 if ( props . disabled ) {
97103 return ;
98104 }
0 commit comments