是的,使用 typescript ReactJS

问题描述

我有以下用打字稿编写的 yup 验证架构:

anotherShippingAddress: bool(),shippingAddress: object().when('anotherShippingAddress',{
    is:true,then: object().shape({
        name: string().when(['firstname','surname'],{
            is: (firstname: string,surname: string) => !firstname && !surname,then: string().required(t('validation.required')).nullable(),otherwise: string().notrequired().nullable(),}),firstname:string().when('name',{
            is: (name: string) => !name,then: string().required(t('validation.required')),surname: string().when('name',acronym: string()
            .required(t('validation.required'))
            .max(20,t('validation.maxLength',{ howMany: 20 }))
            .matches(/^[a-zA-Z0-9_]+$/,t('validation.machineUserAcronym')),street: string().required(t('validation.required')),city:string().required(t('validation.required')),},[
    ['surname','name'],['firstname',]),otherwise: object().shape({
  name: string(),firstname:string(),surname: string(),acronym: string(),street: string(),city:string(),})

此验证架构有效,但我遇到了打字稿错误

Type 'ObjectSchema>; serialNumber: StringSchema,string>; ... 8 多 ...;运输地址:OptionalObjectSchema<...>; }>,Record<...>,TypeOfShape<...>,AssertsShape<...>>' 不能分配给类型'ObjectSchemaOf'。 类型'分配>; serialNumber: StringSchema,string>; ... 8 多 ...;运输地址:OptionalObjectSchema<...>; }>' 不能分配给类型 '{ type: BaseSchema; serialNumber: BaseSchema; machineCode: BaseSchema; ... 7 更多 ...;运输地址:ObjectSchemaOf<...> | ObjectSchemaOf<...>; }'。 属性“shippingAddress”的类型不兼容。 类型 'OptionalObjectSchema,TypeOfShape>' 不可分配给类型 'ObjectSchemaOf | ObjectSchemaOf>'。 类型 'OptionalObjectSchema,TypeOfShape>' 不可分配给类型 'ObjectSchemaOf>'。 属性“字段”的类型不兼容。 类型'ObjectShape' 缺少类型'{ type: BaseSchema; 中的以下属性isYupSchema:BaseSchema

我该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...