2
我不知道如果我可以使用枚舉作爲接口的對象鍵.. 我已經建立了一個小測試吧:使用枚舉爲打字稿界面鍵
export enum colorsEnum{
red,blue,green
}
export interface colorsInterface{
[colorsEnum.red]:boolean,
[colorsEnum.blue]:boolean,
[colorsEnum.green]:boolean
}
當我運行它,我」 m得到以下錯誤:
A computed property name in an interface must directly refer to a built-in symbol.
我做錯了或它只是不可能?