I have a TypeScript project in which I'd like to use libmarkov from npm. It provides an ES6-importable class called Generator. You use it via new Generator('some text').
In my local project, I created a file typedefs/libmarkov.d.ts:
export class Generator {
constructor(text: string);
generate(depth: number);
}
I use typings to install it: typings install --save file:./typedefs/libmarkov.d.ts
However, this: let generator = new Generator('Foo Bar Baz');
...generates this compiler error:
Error:(5, 21) TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
I could change my constructor: constructor(text: string) {};
...but this gives:
Error:(2, 31) TS1183: An implementation cannot be declared in ambient contexts.
If it matters, I'm targeting TS 2.0.
exportwithdeclareexport, I still get the error aboutnew. If I then add{}at the end ofconstructor, I still get thenewerror, but also getError:(2, 31) TS1183: An implementation cannot be declared in ambient contexts.