我正在尝试在 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: