I have a JavaScript function that requires a numerical input, as well as some predefined constants at the top level:
var FOO = 1;
var BAR = 2;
The function should only be called using one of these constants.
To ensure type safety in TypeScript, I am attempting to create an interface using an enum:
declare enum MyType {
FOO,
BAR
}
interface MyClass {
process(MyType type);
}
However, when the code is compiled, it outputs MyType.FOO
in the JavaScript file. Is there a way to make it output just FOO
while still maintaining type safety in TypeScript?