最佳答案
enum
as a key to an object in an interface?I wrote the snippet bellow to test if is (or isn't) possible.
export enum colorsEnum{
red,blue,green
}
export interface colorsInterface{
[colorsEnum.red]:boolean,
[colorsEnum.blue]:boolean,
[colorsEnum.green]:boolean
}
However, When I run the snippet, an error occurs that prints the following message:
A computed property name in an interface must directly refer to a built-in symbol.
I'm doing it wrong, or is it simply just not possible?