@@ -34,36 +34,40 @@ const jsonToObjectArray = (json: Object) => {
3434} ;
3535
3636const CONVERTERS = {
37- string : ( v ) => v ,
38- number : ( v ) => Number ( v ) ,
39- boolean : ( v ) => v === 'true' ,
40- array : ( v ) => JSON . parse ( v ) ,
41- object : ( v ) => JSON . parse ( v )
37+ string : ( v : string ) => v ,
38+ number : ( v : string ) => Number ( v ) ,
39+ boolean : ( v : string ) => v === 'true' ,
40+ array : ( v : string ) => JSON . parse ( v ) ,
41+ object : ( v : string ) => JSON . parse ( v )
4242} ;
4343
4444function ClientParamsPage ( ) {
4545 const [ params , setParams ] = useState ( jsonToObjectArray ( getParams ( ) ) ) ;
4646
47- const convertValueForSave = ( t , stringValue : string ) => CONVERTERS [ t ] ( stringValue ) ;
47+ const convertValueForSave = ( t : 'string' | 'number' | 'boolean' | 'array' | 'object' , stringValue : string ) =>
48+ CONVERTERS [ t ] ( stringValue ) ;
4849
4950 const onSubmit = ( e : FormEvent < HTMLFormElement > ) => {
5051 e . preventDefault ( ) ;
5152 e . stopPropagation ( ) ;
5253
5354 const newParams = params . reduce (
54- ( curr , item ) => ( { ...curr , [ `${ item . key } ` ] : convertValueForSave ( item . type , item . value ) } ) ,
55+ ( curr : any , item : { key : any ; type : 'string' | 'number' | 'boolean' | 'array' | 'object' ; value : string } ) => ( {
56+ ...curr ,
57+ [ `${ item . key } ` ] : convertValueForSave ( item . type , item . value )
58+ } ) ,
5559 { }
5660 ) ;
5761 setParamsGlobal ( newParams ) ;
5862 } ;
5963
60- const replace = ( idx : number , val : any ) => setParams ( ( a ) => a . map ( ( entity , i ) => ( i === idx ? val : entity ) ) ) ;
64+ const replace = ( idx : number , val : any ) => setParams ( ( a : any [ ] ) => a . map ( ( entity , i ) => ( i === idx ? val : entity ) ) ) ;
6165
6266 const removeIdx = ( idx : number ) =>
63- setParams ( ( a ) => a . map ( ( entity , i ) => i !== idx && entity ) . filter ( ( entity ) => entity !== false ) ) ;
67+ setParams ( ( a : any [ ] ) => a . map ( ( entity , i ) => i !== idx && entity ) . filter ( ( entity ) => entity !== false ) ) ;
6468
6569 const addRow = ( ) => {
66- setParams ( ( a ) => [ ...a , { key : '' , value : '' } ] ) ;
70+ setParams ( ( a : any [ ] ) => [ ...a , { key : '' , value : '' } ] ) ;
6771 } ;
6872
6973 const changeValue = ( idx : number , value : string , currKey : string , type : string ) => {
@@ -108,7 +112,7 @@ function ClientParamsPage() {
108112 < MenuItem value = { 'number' } > Number</ MenuItem >
109113 < MenuItem value = { 'array' } > Array</ MenuItem >
110114 < MenuItem value = { 'object' } > Object</ MenuItem >
111- < MenuItem value = { 'boolean' } > boolean </ MenuItem >
115+ < MenuItem value = { 'boolean' } > Boolean </ MenuItem >
112116 </ Select >
113117 </ FormControl >
114118 < IconButton sx = { { margin : '10px' } } color = "error" onClick = { ( ) => removeIdx ( idx ) } >
0 commit comments