【发布时间】:2017-02-03 17:16:20
【问题描述】:
我想知道我是否可以在接口中使用枚举作为对象键.. 我已经为它构建了一个小测试:
export enum colorsEnum{
red,blue,green
}
export interface colorsInterface{
[colorsEnum.red]:boolean,
[colorsEnum.blue]:boolean,
[colorsEnum.green]:boolean
}
当我运行它时,我收到以下错误:
A computed property name in an interface must directly refer to a built-in symbol.
我做错了还是不可能?
【问题讨论】:
标签: typescript enums