In my TypeScript project I want to use Logdown.
Logdown can be used in a Node.js application like this:
var Logdown = require('logdown')
var logger = new Logdown({prefix: 'test'})
logger.info('Hello World');
Unfortunately, Logdown does not provide declarations, so I wanted to write a declaration file.
To kickstart this little project, I did the following:
- I cloned the Logdown repository
- I created a "typings" entry in the
package.jsonfile of the cloned Logdown repository and pointed it dodist/logdown.d.ts(according to "Including declarations in your npm package") - I made the cloned Logdown repository locally available as npm package (
npm link) - I ran
npm link logdownwithin my TypeScript application to point this Node module reference to my cloned repository
After that I created the content for the logdown.d.ts file:
export declare class Logdown {
constructor(options: Object);
public info(text: string): string;
}
I was hoping that I can use now Logdown in my TypeScript project like this:
import Logdown = require("logdown");
let logger: Logdown = new Logdown();
logger.info('Hello World!');
But when I compile the project, I get the following errors:
error TS2304: Cannot find name 'Logdown'.
error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
typesinpackage.json, nottypings. Also, this does not works for typescript older than 2.0.logdown.d.ts.