Reputation: 961
I've been searching for hours now and can't find a straight answer on this. I am creating a nodejs project which is using the node.d.ts declaration file.
I want to create a new declaration file in my project that will hold all the interfaces.
In this file 'Controller.d.ts' I have the following:
/// <reference path="./interfaces/node.d.ts" />
import http = require( "http" );
interface IController
{
processRequest( request: http.ServerRequest, response: http.ServerResponse, queryData: any );
}
However by using the import statement in the declaration file, none of the ts files recognise IController. Only if I remove the import does it work. But if I remove the import then the Controller.d.ts file is incorrect as it doesn't know what the "http" module is.
How can I reference the http module in my declaration file?
Any help would be greatly appreciated
Upvotes: 1
Views: 405
Reputation: 106620
Change Controller.d.ts
to export IController
like so:
import http = require("http");
interface IController {
processRequest( request: http.ServerRequest, response: http.ServerResponse, queryData: any );
}
export = IController;
Then in your application's typescript file, reference Controller.d.ts
by doing this (change the path if necessary):
import IController = require("./Controller");
Now you can reference IController
.
Upvotes: 1