I\'ve searched around but can\'t seem to find an answer for this, hopefully you can help. How can I add an enum to Image? This is what I would like ideally but I get an error.>
I also bumped into this problem recently. This is what I am currently using as a solution:
// File: Image.ts
class Image
{
constructor()
{
this.state = Image.State.Idle;
}
state: Image.State;
}
module Image
{
export enum State
{
Idle,
Loading,
Ready,
Error
}
}
export = Image;
Then in the place where I'm using the class and its enum:
import Image = require("Image");
let state = Image.State.Idle;
let image = new Image();
state = image.state;
This seems to work fine (even though I don't consider it as the expected way to do this kind of thing).
Hopefully there will be a way in TypeScript to do it this way:
class Image
{
enum State
{
Idle,
Loading,
Ready,
Error
}
constructor()
{
this.state = State.Idle;
}
state: State;
}
export = Image;