是否推荐在 TypeScript 中以这种方式实现接口?

Is it recommended to implement the interface this way in TypeScript?

对于接口中的函数类型声明;将接口中另一个功能调用的描述声明为 return 类型是推荐的还是好的做法?下面是我的意思的基本示例。

testFunction 作为参数的组件调用:

<Component
 testFunction={() => {

 // Function happens here as described in interface declaration

 }} 
/>

接口声明:

interface Props {
  testFunction: () => "Description of what the function does";
}

像这样声明接口:

interface Props {
  testFunction: () => "Description of what the function does";
}

只会从函数中指定 return 是 string 的值:"Description of what the function does".

该函数的名称,在您的例子中 testFunction 应该是不言自明的。 示例:onClickhandleUpload