0

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mochics
  • 57
  • 1
  • 7

1 Answers1

0

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.

Andrei Zhytkevich
  • 8,039
  • 2
  • 31
  • 45
  • IME "triple-slash references" are best avoided. Assuming you have a `tsconfig.json` at the root of your project, you can simply add any external typings to the `files` array, before your entry point. – linguamachina Jul 10 '16 at 21:14
  • @Andrei Zhytkevich Thanks, I'll have a look. – Mochics Jul 14 '16 at 10:49