I have an Angular 1.x application built with Gulp. My enums are defined in a separate auto-generated file named enums.ts.
The enum content is as follows:
declare module MyApp.App {
export enum Status {
Done = 0,
Unsuccessful = 1,
Pending = 2,
}
The class that utilizes this enum is located in a different file called class.ts
namespace MyApp.App {
export class ResourcesCtrl implements IResourcesCtrl {
public loading: boolean;
public resources: IResource[];
public isSucessfull(resource: IResource): boolean {
return resource.status.toString() !== Status.Done.toString();
}
}
angular.module("app").
controller("resourcesCtrl",ResourcesCtrl);
}
When the file is processed by the TypeScript compiler, the output JavaScript file is always empty.
If I move the enum to the same file as the class that uses it, everything works correctly.
namespace MyApp.App {
export enum Status {
Done = 0,
Unsuccessful = 1,
Pending = 2,
}
export class ResourcesCtrl implements IResourcesCtrl {
public loading: boolean;
public resources: IResource[];
public isSucessfull(resource: IResource): boolean {
return resource.status.toString() !== Status.Done.toString();
}
}
angular.module("app").
controller("resourcesCtrl",ResourcesCtrl);
}