Use node module in typescript environment

117 views Asked by At

I've been trying to use the node modules 'markdown' and 'dustjs-helpers' in my angular 2.0 client side. The thing is that I couldn't reach a solution using typings (both packages are not available on typings) and I wonder if there is a way to use them in angular 2.0.

I have to use them on the client side because I can't overload the server with many requests.

1

There are 1 answers

2
Andrei Zhytkevich On BEST ANSWER

You can create a simple type definition file for those libraries.

Create a file mytype.d.ts:

interface Widget {
    render(): void;
    getInfo(): void;
}

Add this reference to your .ts file":

///<reference path="mytype.d.ts" /> 

Make sure the path is correct.

More details: https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html.