Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 类型';PartialDeep<;StringSchema>';不可分配给类型';图式<;{}>';。TS2345_Typescript_Lodash_Typescript3.0 - Fatal编程技术网

Typescript 类型';PartialDeep<;StringSchema>';不可分配给类型';图式<;{}>';。TS2345

Typescript 类型';PartialDeep<;StringSchema>';不可分配给类型';图式<;{}>';。TS2345,typescript,lodash,typescript3.0,Typescript,Lodash,Typescript3.0,我在使用typescript提取JSON对象的值时遇到了这个错误 这是JSON对象: const schema = { firstName: yup .string() .required(REQUIRED_FIELD_MESSAGE) .min(1) .max(50) } 我有一个字符串[]: list = [ "firstName" ] 然后使用pick仅从const schema获取键值对,如果我使用: pick(schema, l

我在使用typescript提取JSON对象的值时遇到了这个错误

这是JSON对象:

const schema = {
  firstName: yup
   .string()
   .required(REQUIRED_FIELD_MESSAGE)
   .min(1)
   .max(50)
}
我有一个字符串[]:

list = [
        "firstName"
     ]
然后使用pick仅从const schema获取键值对,如果我使用:

pick(schema, list)
我得到以下错误

Types of property 'firstName' are incompatible.
    Type 'PartialDeep<StringSchema> | undefined' is not assignable to type 'Ref | Schema<{}> | undefined'.
      Type 'PartialDeep<StringSchema>' is not assignable to type 'Ref | Schema<{}> | undefined'.
        Type 'PartialDeep<StringSchema>' is not assignable to type 'Schema<{}>'.  TS2345
属性“firstName”的类型不兼容。
类型“PartialDeep | undefined”不可分配给类型“Ref | Schema | undefined”。
类型“PartialDeep”不可分配给类型“Ref | Schema | undefined”。
类型“PartialDeep”不可分配给类型“Schema”。TS2345