标签: typescript
给出一个带有字符串值的枚举,为什么我不能用该类型的文字字符串分配该类型的变量。
enum Testing { testing = 'test', } const foo: Testing = 'test'; // error 'test' is not assignable to type Testing
但是:
enum NumberType { first = 0, } const first: NumberType = 0; // works