使用进口时,这是文件级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)
})
}
}
}
当我访问该命名空间在另一个文件中的代码来访问命名空间或类,我得到的编译错误“无法寻找服务“。
这是文件中的代码-server.ts
/// <reference path="App.ts" />
var Server = new Service.AppServer();
var Config = <Service.Configuration>{
Port: 3000
}
Server.StartServer(Config);
但是当我删除它需要HTTP和表达import语句,我也不多收到错误的文件中。 请帮我找到 - 我在哪里做错了?
错误我是gettinf是 - 'ts2304'找不到名字'service'。
你能引用错误信息吗? – enkryptor
根据错误你无法找到哪种服务?它是用于你的'Service'模块还是用于'express','fs'或'http'? – ranakrunal9
我已经更新了问题,顺便说一句,我得到的错误是'ts2304'找不到名称'服务'。 –