I declare a map so I can convert the numeric enum value into the value our API expects.
export const StatusMap: ReadonlyMap<Status, string> = new Map([
[Status.NEW, 'new'],
[Status.PENDING, 'pending'],
]);
But when I do statusMap.get(Status.NEW)
it always tells me that the return value is possibly undefined. Is there a way to force a map (or similar) to contain all enum values?
And yes I know you can technically do
export enum Status {
NEW = 'new',
PENDING = 'pending',
}
but let's be honest, this kind of ruins the point of enums (IMO).