简体   繁体   English

Typescript 类型签名 function 对象数组参数

[英]Typescript type signature function array of objects parameter

What is the syntax to define onChange in this interface:在这个接口中定义 onChange 的语法是什么:

interface myInterface{
   data: Type1
   onChange : ({field: string, value: any}[]) => void
}

It gives me compile error on '=>' (; expected) I want to say onChange receives an array of field-value pair and return type is void.它给了我在'=>'(; 预期)上的编译错误我想说 onChange 接收到一个字段值对数组并且返回类型为 void。 What is the syntax?语法是什么?

Your forgot about :你忘了:

interface myInterface{
  data: Type1
  onChange: (arr: {field: string, value: any}[]) => void
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为对象提供类型时,TypeScript 中没有带有“字符串”类型参数的索引签名错误 - No index signature with a parameter of type 'string' Error in TypeScript while giving types to Objects 打字稿 - 没有带有“字符串”类型参数的索引签名 - Typescript - No index signature with a parameter of type 'string' 反应 Typescript 在类型上找不到参数类型为“string”的索引签名 - React Typescript No index signature with a parameter of type 'string' was found on type 打字稿错误:在类型“{}”上找不到带有“字符串”类型参数的索引签名 - Typescript error : No index signature with a parameter of type 'string' was found on type '{}' 反应和 typescript - 在类型 x 上没有找到带有“字符串”类型参数的索引签名 - react and typescript - no index signature with a parameter of type 'string' was found on type x TypeScript:尝试访问枚举时,没有带有“字符串”类型参数的索引签名 - TypeScript: No index signature with a parameter of type 'string' when try to access the Enum Typescript 不能缩小 function 对组件道具总和类型的签名 - Typescript can't narrow function signature on sum type of component props TypeScript - 如何从对象数组推断类型 - TypeScript - How to infer a type from array of objects Typescript 索引签名错误:类型错误:类型参数不可分配给“SetStateAction”类型的参数<never[]> '</never[]> - Typescript index signature error : Type error: Argument of type is not assignable to parameter of type 'SetStateAction<never[]>' 如何在 TypeScript 中将 function 类型声明为参数 - How to declare a function type as a parameter in TypeScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM