node.js and typescript definition file for async.js

I am trying to create the following in 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;
}

but i am not allowed to make the err? optional in the AsyncIteratorCallback?

when i use it:

async.each([],(item,cb) => {},(err) => {});

i get Call signatures of types '(err: string) => void' and '"async".AsyncIteratorCallback' are incompatible:

UPDATE:

I tried this code in Visual Studio 2012

interface test {
    (err:string):void
}

var a = (err: string) => { };
var b = (param: test) => { };
b(a);

It works. Apparently the function a implements the interface test. Then I changed this code to:

interface test {
    (err?:string):void
}

var a = (err: string) => { }; 
var b = (param: test) => { };
b(a);  // error, incompatible call signatures

Now the function doesn't implement the interface. The solution is to add an ? to the function parameter, too. This code works again:

interface test {
    (err?:string):void
}

var a = (err?: string) => { }; 
var b = (param: test) => { };
b(a);  // error, incompatible call signatures

Finally I tried the following:

interface test {
    (err:string):void
}

var a = (err: string) => { };
var b = (param: test) => { };
b({ method:a });  // error, no overload of call

I had already wondered about the interface definition since I had never seen an interface with a method without name. It seems that an object can't implement this interface. Even this code doesn't work:

b({ call: a });

Solution

You should just add the ? to your lambda. (err?)=>{}