I've been pouring through StackOverflow posts and multiple blog posts, but can't seem to find the answer.
I'm using VS Code, nodejs, typescript and gulp. When I place all of my module Controllers code into one file like this:
<controllers.ts>
module Controllers {
export class Api {
get(controllerName:string):IController {
}
}
}
module Controllers {
export interface IController {
performAction(actionName:string):any;
}
}
module Controllers {
export class ControllerBase implements IController {
performAction(actionName:string):any {
}
}
}
module Controllers {
export class UserController extends ControllerBase {
}
}
export = Controllers;
Gulp is able to compile it and nodejs runs it correctly.
When I break it into multiple files though, I can't seem to get it to compile:
<controllers.ts>
module Controllers {
export class Api {
get(controllerName:string):IController {
}
}
}
module Controllers {
export interface IController {
performAction(actionName:string):any;
}
}
module Controllers {
export class ControllerBase implements IController {
performAction(actionName:string):any {
}
}
}
export = Controllers;
<UserController.ts>
module Controllers {
export class UserController extends ControllerBase {
}
}
I've tried adding
/// <reference path="./controllers.ts" />
to the top of my UserController.ts file. When I do that, it still can't find ControllerBase.
I tried doing
export class Controllers.UserController extends Controllers.ControllerBase
and it doesn't like the Controllers before UserController, but if I remove that Controllers and make it look like this:
export class UserController extends Controllers.ControllerBase
then obviously it places UserController in a different module.
Also, importing it like this:
import Controllers = require("./controllers");
doesn't seem to help either. I'm not sure what else to try. Any help would be greatly appreciated. It doesn't seem like this shouldn't be achievable.