user799755
user799755

Reputation:

Ambient TypeScript Modules in node.js

I'm trying to write an ambient module in node.js using the Visual Studio developer tools.

The module looks like this

module "Module" {
   export class Class {
       first = "First";
       second = "Second";
   }
}

I think attempt to use this in another file:

var m = require("Module");
var c = new m.Class();

The typing on the require statement is fine, but this gives a compiler error, saying "Only ambient modules can use quoted names".

How then am I supposed to write my TypeScript modules such that they can be imported into other project files, and the import is strongly typed?

Upvotes: 2

Views: 1229

Answers (1)

Louay Alakkad
Louay Alakkad

Reputation: 7408

Use declare.

declare module "Module" ...

Upvotes: 2

Related Questions