In the process of refactoring a large codebase, I came across this original definition:
export const enum Direction {
NORTH,
SOUTH,
}
and various instances of code using it, like so:
console.log(Direction.NORTH);
Now, with the updated definition being:
namespace xyz {
export const enum Direction {
NORTH,
SOUTH,
}
}
This allows me to now write:
console.log(xyz.Direction.NORTH);
However, I want to avoid modifying the existing code that accesses the enum values.
I attempted to do the following:
namespace xyz {
export const enum Direction {
NORTH,
SOUTH,
}
}
console.log(xyz.Direction.NORTH);
export type Direction = xyz.Direction;
console.log(Direction.NORTH);
But, encountered an error on the last line:
'Direction' only refers to a type, but is being used as a value here.