Argument of type '(Promise<void> | Promise<WriteResult>)[]' is not assignable to parameter of type 'IterableType '() => IterableIterator<Promise<void> | Promise<WriteResult>>' is not assignable to type
我有一个返回值为Promise<T>或undefined的函数callback<T>。现在我想创建一个包装函数,它将执行函数并始终返回Promise -如果回调函数返回undefined,Promise应该用undefined解析。代码不是问题,但在Typescript中维护类型推断。函数签名必须看起来如何才能保持类型?(非工作)示例:
function wrap<T>(callback: () => Promise<T> | und
我有一个异步函数: async getItems() : Promise<any[]> {} 这会获取一些数据。对Table组件的函数调用: dataSource={this.props.itemsStore.getItems()} 错误消息: Type 'Promise<any[]>' is missing the