【发布时间】:2013-06-20 03:42:36
【问题描述】:
我正在尝试在 async.d.ts 中创建以下内容:
interface AsyncIteratorCallback {
(err?: string): void;
}
interface AsyncEachIterator<T>{ (item: T, callback: AsyncIteratorCallback): void;}
declare module "async" {
// Collections
function each<T>(arr: T[], iterator: AsyncEachIterator<T>, callback: AsyncIteratorCallback): void;
}
但我不允许犯错?在 AsyncIteratorCallback 中可选?
当我使用它时:
async.each([],(item,cb) => {},(err) => {});
我收到Call signatures of types '(err: string) => void' and '"async".AsyncIteratorCallback' are incompatible:
【问题讨论】:
标签: node.js asynchronous typescript