Reputation: 2376
This is the code in file- app.ts
import Express = require('express');
import FileSystem = require('fs');
import Http = require('http');
module Service {
export interface Configuration {
Port: number,
Host: string
}
export class AppServer {
App: Express.Application;
AppServer: Http.Server;
constructor() {
this.App = Express();
this.App.use(this.App.route);
// this.App.use(this.App.router);
}
/**
* Start the server
* @param {Configuration} config
*/
StartServer = function (config: Configuration) {
var That = this;
this.AppServer = this.App.listen(config.Port, function () {
var Host = That.AppServer.address().address;
var Port = That.AppServer.address().port;
console.log("Example app listening at http://%s:%s", Host, Port)
})
}
}
}
when i am accessing the namespace in another file, i am getting the compile error that "unable to find service".
this is the code in file -server.ts
/// <reference path="App.ts" />
var Server = new Service.AppServer();
var Config = <Service.Configuration>{
Port: 3000
}
Server.StartServer(Config);
but when i am removing the import statement which is requiring http and express, i am no more getting the error in the file. Please help me to find- where i am doing wrong?
the error i am gettinf is - 'ts2304' can not find name 'service'.
Upvotes: 0
Views: 1371
Reputation: 1125
It seems like you have not exported the module. Try adding export {Service}
at the end of your file.
Upvotes: 2