I\'d like to somehow be able to statically set an enum on my TypeScript class and be able to reference it both internally and externally via exporting the class. I\'m fairly new
You can declare a namespace right after your class, and declare the enum inside the namespace. For example:
class UnitModel extends Backbone.Model {
defaults(): UnitInterface {
return {
status: UNIT_STATUS.NOT_STARTED
};
}
isComplete(){
return this.get("status") === UNIT_STATUS.COMPLETED;
}
complete(){
this.set("status", UNIT_STATUS.COMPLETED);
}
}
namespace UnitModel {
export enum UNIT_STATUS {
NOT_STARTED,
STARTED,
COMPLETED
}
}
export = UnitModel;
Then you can use UnitModel.UNIT_STSTUS
to reference you enum.