wangdoc / typescript-tutorial

TypeScript 教程
https://wangdoc.com/typescript
2.49k stars 269 forks source link

内容表述不严格 #85

Closed HuangZhuo closed 11 months ago

HuangZhuo commented 11 months ago

https://github.com/wangdoc/typescript-tutorial/blob/8ad5fc69f7e19dd117ddfc60b3dee299afca0180/docs/enum.md?plain=1#L515

实测这句话仅当 MyEnum 是数值 Enum 时生效,但前文例子中用的是字符串 Enum,实际是 keyof string

测试:https://www.typescriptlang.org/play?#code/KYOwrgtgBAsgngUXBAylA3gKCjqBBKAXigHIBDEgGkwF9NRJZFkA5DbXPSgem+PKq1MAFzgAHYLAQoA0kSgBrYHAD2AMyZJIKANwjxkmAhZziS1RvhaILPUA

HuangZhuo commented 11 months ago

https://github.com/wangdoc/typescript-tutorial/blob/8ad5fc69f7e19dd117ddfc60b3dee299afca0180/docs/enum.md?plain=1#L527

还有一点疑问:「返回 Enum 所有的成员值」的说法更加倾向于表示「值运算」,因此可能 Object.values 更加贴切点。考虑反向映射,可能取成员值这个操作比较适合字符串 Enum

ruanyf commented 11 months ago

谢谢指出,已经更正。