I have received a string from an API and need to generate another string based on it.
The possible values for the received string from the API are:
"customField" | "customForm" | "customAction"
. The provided code demonstrates how I am currently handling this, but I am unsure if this approach is future-proof. Is there a more adaptable or idiomatic way to achieve this?
private getTitleFromType(
currentType: "customField" | "customForm" | "customAction"
): "Field" | "Form" | "Action" | "" {
switch (currentEditorType) {
case "customField":
return "Field";
case "customForm":
return "Form";
case "customAction":
return "Action";
default:
return "";
}
}