我无法实现接口的方法,我得到错误ReferenceError: INew is not defined
而不是
我有以下文件:
1个新服务
import express = require("express");
import NewController = require("../controllers/NewController");
var router = express.Router();
class NewRoutes {
private _newController: NewController;
constructor () {
this._newController = new NewController();
}
get routes () {
var controller = this._newController;
router.get("/new", controller.retrieve);
return router;
}
}
Object.seal(NewRoutes);
export = NewRoutes;
2控制器
import INew = require("../interfaces/INew");
class NewController{
private _INew: INew;
constructor(){
this._INew = new INew(); // !!!! INew became RED --> cannot find name 'INew'
}
retrieve(req: express.Request, res: express.Response): void {
try {
console.log('--------------NewController-----------------');
this._INew.findById(2);
}
catch (e) {
console.log(e);
}
}
}
Object.seal(NewController);
export = NewController;
3 INew
interface INew {
findById: (id: number) => void;
}
export = INew;
4 NewRepository
import INew = require("../interfaces/INew");
class NewRepository implements INew {
constructor() {
}
findById(id) {
console.log('RESULT');
}
}
Object.seal(NewRepository);
export = NewRepository;
当我尝试构建应用时,我收到错误:
this._INew = new INew();
^
ReferenceError: INew is not defined
请帮助