2016-10-04 4 views
0

Typescript에서 비동기 라이브러리를 사용하려고합니다. 나는 typings에 의해 제공했다 정의 파일을 설치 한하지만 난 AsyncFunction을 사용할 수 없습니다 : 나는이 오류가있어이 추출물을 컴파일하는 경우Nodejs, Typescript, 타이핑 : 비동기 라이브러리 사용법

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

import async = require('async'); 

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

가 :

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'. 

내가 사용하는 비동기 정의 파일이 이 : https://raw.githubusercontent.com/types/npm-async/ff63908a70ec51b775d9a6b8afac9945b12fbe08/2/index.d.ts

내가 뭘 잘못하고있어?

감사합니다.

+0

누군가가 같은 문제를 안고있는 경우, 내 솔루션은 글로벌 정의 dt ~ async를 설치하는 것이 었습니다 – Steve81

답변

0

AsyncFunction 인터페이스에서 해당 파일을 내보낼 수 없습니다. 마지막 줄에 export = async;에서 볼 수있는 유일한 수출은 async입니다.

수정

해당 주석을 사용해야하는 경우 global.d.ts interface AsyncFunction<T> { (callback: (err?: Error, result?: T) => void): void; }를 복사하시기 바랍니다.

+0

고맙습니다. 왜 내가 혼란 스러웠는지 이해합니다 : 비동기 v1 정의는 "모듈"을 사용하지 않기 때문에 모든 인터페이스가 직접적입니다. 사용할 수 있습니다. – Steve81

+0

@ Steve81이 오류가 발생한 이유를 더 자세히 설명 할 수 있습니까? – blackHawk