2

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?

1 Answer 1

2

Use declare.

declare module "Module" ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.