Steve81 Steve81 - 5 months ago 34
TypeScript Question

Nodejs, Typescript, typings: how to use async library

I'm trying to use the async library in Typescript; I've installed the definition file that was provide by typings but I cannot use AsyncFunction:

///<reference path='typings/index.d.ts' />
'use strict';

import async = require( 'async' );

let functions : AsyncFunction<any>[] = [];

If I compile this extract I got this error:

tsc test.ts --target es2015 --module system --removeComments --forceConsistentCasingInFileNames --noEmitOnError --noFallthroughCasesInSwitch --noImplicitAny --noImplicitReturns --noImplicitUseStrict --declaration --outfile a.js
test.ts(4,17): error TS2304: Cannot find name 'AsyncFunction'.

The async definition file that I use is this:

What I'm doing wrong?

Thank you!


The interface AsyncFunction is not exported from that file. The only export is async as you can see from export = async; on the last line.


Feel free to copy interface AsyncFunction<T> { (callback: (err?: Error, result?: T) => void): void; } to a global.d.ts if you must use that annotation.