After referencing this question and answer on Stack Overflow about setting a static enum inside a TypeScript class, I decided to create my own enum and implement it as a static property in my class. Here is how I did it:
/* Input.ts */
enum INPUT_TYPE { TEXT, RADIO, CHECKBOX }
export class Input {
static INPUT_TYPE = INPUT_TYPE;
readonly inputType: INPUT_TYPE;
constructor (inputType: INPUT_TYPE) {
this.inputType = inputType;
}
}
This is just a simple example class for demonstration purposes.
Now, I have another class in a separate file that needs to utilize the previously created class.
import {Input} from "./Input";
/* InputLabel.ts */
export class InputLabel extends Input {
readonly label: string;
constructor(label:string, inputType: Input.INPUT_TYPE) {
super(inputType);
this.label = label;
}
}
I am using IntelliJ IDEA and have configured the TypeScript version to match my current version (2.0.2). However, IntelliJ is showing an error stating that it cannot find the namespace 'Input'.