Within my code, I have an enum that includes a collection of strings
export enum apiErrors {
INVALID_SHAPE = "INVALID_SHAPE",
NOT_FOUND = "NOT_FOUND",
EXISTS = "EXISTS",
INVALID_AUTH = "INVALID_AUTH",
INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR"
}
I have created an interface as follows:
export interface IApiResponse {
status: boolean;
payload: any;
errorCode?: string; // I would like this to only accept values like "INVALID_SHAPE" or "NOT_FOUND" and so forth...
}
I am aware that I could simply use "INVALID_SHAPE" | "NOT_FOUND"
Is there a method to destructure the enum for errorCode
in order to restrict it to accept only those specific strings?