Javascript T扩展ChangeEvent<;任何>?void:(e:string | changevent<;any>;)

Javascript T扩展ChangeEvent<;任何>?void:(e:string | changevent<;any>;),javascript,reactjs,typescript,react-native,formik,Javascript,Reactjs,Typescript,React Native,Formik,我在屏幕中使用了自定义的formik组件,如下所示: <Formik initialValues={initialValues} onSubmit={handleSubmitForm} validationSchema={validationSchema}> {({ handleChange, handleBlur, handleSubmit, value

我在屏幕中使用了自定义的formik组件,如下所示:

 <Formik
                initialValues={initialValues}
                onSubmit={handleSubmitForm}
                validationSchema={validationSchema}>
                {({ handleChange, handleBlur, handleSubmit, values }) => (
                  <View style={styles.searchFieldContainer}>
                    <View style={styles.form}>
                      <FieldInput
                        handleChange={handleChange}
                        handleBlur={handleBlur}
                        value={values.phoneNumber}
                        fieldType="phoneNumber"
                        icon='phone'
                        placeholderText='49152901820'
                      />
                      <ErrorMessage
                        name="phoneNumber"
                        render={(msg) => (
                          <Text style={styles.errorText}>{msg}</Text>
                        )}
                      />
                    </View>
                    <View style={styles.buttonContainer}>
                      <Button
                        onPress={handleSubmit}>
                        Search
                      </Button>
                    </View>
                  </View>
                )}
              </Formik>

{({handleChange,handleBlur,handleSubmit,values})=>(
(
{msg}
)}
/>
搜索
)}
我在handleChange和handleBlur上得到一个TypeScript错误:

Type '{ (e: ChangeEvent<any>): void; <T = string | ChangeEvent<any>>(field: T): T extends ChangeEvent<any> ? void : (e: string | ChangeEvent<any>) => void; }' is not assignable to type '(e: string) => undefined'.
  Types of parameters 'e' and 'e' are incompatible.
    Type 'string' is not assignable to type 'ChangeEvent<any>'

FieldInput.tsx(9, 3): The expected type comes from property 'handleChange' which is declared here on type 'IntrinsicAttributes & FieldInputProps & { children?: ReactNode; }'
类型“{(e:ChangeEvent):void;(字段:T):T扩展ChangeEvent?void:(e:string | ChangeEvent)=>void;}”不可分配给类型“(e:string)=>undefined”。
参数“e”和“e”的类型不兼容。
类型“string”不可分配给类型“ChangeEvent”
tsx(9,3):预期的类型来自属性“handleChange”,该属性在类型“IntrinsicatAttributes&FieldInputProps&{children?:ReactNode;}”上声明

字段输入应该是字符串,我不认为应该将ChangeEvent的类型更改为字符串“任何”也不是一个好的选择。如何修复此问题?

我相信这条线会导致错误

onChangeText={handleChange(fieldType)}
因为handleChange(fieldType)是一个字符串,所以将其转换为函数

onChangeText={(e: any) => handleChange(fieldType)}

可能会修复错误

不幸的是,它无法修复问题