When working with a Typescript module, it is possible to import various exports including classes, interfaces, variables and enums that were exported using the old export = syntax.
However, I have noticed that when attempting this with an ambient module, the compiler (version 1.8.10) does not seem to recognize the import statement.
Declaration File:
//Module declaration
declare module "foo" {
interface barProc {
(): any;
}
//Note: if I use the function equivalent to the interface this works ok.
function worksOk(): any;
export = barProc;
}
Main File:
//Module usage
import myFunc = require("foo");
myFunc();
In this scenario, the compiler raises an error stating that myFunc is an unknown identifier and the import line doesn't show up in the output Javascript file.
Note: Although in the example illustrated, no other members are added to the interface for simplicity reasons, the interface is used because the JavaScript library being modeled has members on the function.
Is there anything wrong with how I'm doing this, or is there a workaround available?