I am refactoring a large codebase, which contained this definition:
export const enum Direction {
NORTH,
SOUTH,
}
and much code like this:
console.log(Direction.NORTH);
The new definition is this:
namespace abc {
export const enum Direction {
NORTH,
SOUTH,
}
}
With it, I can write this:
console.log(abc.Direction.NORTH);
Though, I don’t want to change the code above to access the enum values.
I tried to write this:
namespace abc {
export const enum Direction {
NORTH,
SOUTH,
}
}
console.log(abc.Direction.NORTH);
export type Direction = abc.Direction;
console.log(Direction.NORTH);
Though, at the last line, I get the error:
'Direction' only refers to a type, but is being used as a value here.
user27357906 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
Export Direction as both a type and a value:
namespace abc {
export const enum Direction {
NORTH,
SOUTH,
}
}
export import Direction = abc.Direction;
Aras Bulak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1