我正在使用一个用于 TS 生成的库(ts-protoc-gen),它为枚举生成以下内容:
export interface AnimalTypeMap {
Dog: 0;
Cat: 1;
Fish: 2;
Bird: 3;
}
export const AnimalType: AnimalTypeMap;
- 我应该如何消费它?
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
- 它如何在不初始化的情况下导出 const?