我正在尝试在Typescript中实现类似以下示例的内容:const orangeOption:string = 'Orangeso that it's easier for me to refactor them in future我希望使用变量,而不是将联合类型作为FruitType的文字字符串键入,这样当我需要再次<e
这不是:Check if value exists in enum in TypeScript的副本,后者根据枚举值检查类型枚举。没有其他关于TypeScript如何检查字符串或字符串文字与枚举相关的帖子。原因是我通过API接收数据,所以它的原始类型是字符串。if (c.name().equals(test)) { } return false;
} 在TypeScript</