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'm not sure what you intend to do, but I would have expected that you would want an enum
to represent the possible state values, and then a state
member on the image to indicate the current state of the image.
declare module 'Lib' {
export module Graphics {
enum State {
STATE_IDLE,
STATE_LOADING,
STATE_READY,
STATE_ERROR
}
export class Image {
public state: State;
constructor();
}
}
}
It sounds like you want to declare a class that has enum-like members, rather than declare an enum within a class. i.e:
declare module 'Lib' {
export module Graphics {
export class Image {
static STATE_IDLE: number;
static STATE_LOADING: number;
static STATE_READY: number;
static STATE_ERROR: number;
constructor();
}
}
}