我正在尝试声明可以将函数或对象作为参数的函数类型,但结果是Cannot call `data` because a callable signature is missing in `TestObject` [1].
这是我试图实现的基本代码示例。
type TestObject = {
name: string
}
const dummyFunction = (data: TestObject | (props:Object)=> TestObject) => {
typeof data === 'function' ? props => data(props): data;
return {} // empty object just for the test purpose
}
或链接到flow-type
我想念什么?