I'm working with a library proto file that generates an interface, that should be able to be used as an enum:
export interface FinishReasonMap {
NULL: 0;
LENGTH: 1;
STOP: 2;
ERROR: 3;
FILTER: 4;
}
The types are auto-generated from a .proto definition, so its hard to update them to be a basic enum.
now, I can use that in my own type def like:
export type ImageObject = {
finishReason?: FinishReasonMap[keyof FinishReasonMap];
}
but I'm not able to use it for a comparison, eg:
if (item.finishReason === FinishReasonMap.FILTER) { ...
error: 'FinishReasonMap' only refers to a type, but is being used as a value here.
I know TS enum's are a bit funky sometimes, but not clear how to use this. I think I want something like the opposite of typeof to get enum values from the interface?