【发布时间】:2021-10-10 16:49:50
【问题描述】:
为方便起见,我想合并两个单独的枚举。
export enum ActionTypes1 {
ClearError = 'CLEAR_ERROR',
PrependError = 'PREPEND_ERROR',
}
export enum ActionTypes2 {
IncrementCounter = 'INCREMENT_COUNTER',
}
是否可以调用一个枚举来访问两者的数据?
例如
Foo.ClearError // works
Foo.IncrementCounter // works
对于上下文,我使用枚举作为函数名称。在这里用一个常量替换枚举:
// Error: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.
async [ActionTypes.IncrementCounter]({ commit }) {
【问题讨论】:
-
您可能正在寻找工会stackoverflow.com/a/60041791/4541045
-
这能回答你的问题吗? How to merge two enums in TypeScript
标签: typescript