Utilizing a TypeScript to proto file generator library (ts-protoc-gen), results in the generation of the following code snippet for enums:
export interface AnimalTypeMap {
Dog: 0;
Cat: 1;
Fish: 2;
Bird: 3;
}
export const AnimalType: AnimalTypeMap;
- What is the recommended way to utilize this generated code?
if (arg === AnimalType.Bird) {} // **ERROR**: Variable 'AnimalType' is used before being assigned
if (arg === AnimalTypeMap.Bird) {} // **ERROR**:'AnimalTypeMap' only refers to a type, but is being used as a value here
- Is it possible for a constant to be exported without initialization like this?