2016-07-10 6 views
1

도서관에 node_modules/이 설치되어있어 타이프 스크립트 앱에서 사용할 수 있도록 빠른 해킹을 원합니다. 폴더 typings/modules에 모듈의 이름과 index.d.ts 파일의 폴더가 생성되었습니다. 해당 파일의 내부에서 나는 모듈을 가져올 수있어ts 입력란을 만드는 방법

declare module "lib-name" { 
    export default class Logger { 
    constructor(namespace: string) 
    } 
} 

은 가지고 있지만, 내가 let l = new Lib('namespace');하려고 할 때 나는 당신이 당신의 typings에서 class을한다고 생각하지 않습니다 오류 cannot use 'with' an expression whose type lacks a call or construct signature

답변

1

을 얻고있다. 선언해야하는 인터페이스 계약입니다.

는 또한 문서는 새로운 표현은 인터페이스에 new 방법이 필요하다고 말한다 :이 어쩌면 같은 https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html

시도 뭔가 :

declare module "lib-name" { 
    interface Logger { 
    new (namespace: string): Logger 
    } 

    export var Logger: Logger; 
} 
+0

하나님이 당신을 축복! –

관련 문제