TypeScript TS7015 error when accessing an enum using a string type parameter

前端 未结 4 1985
执笔经年
执笔经年 2020-12-02 16:50

I am new to TypeScript and I don\'t understand the what I need to do to fix the line that generates the TS7015 error (referencing an enum member using a string variable) bec

4条回答
  •  情书的邮戳
    2020-12-02 17:30

    var stateName = "Happy"
    var state = parseInt(State[stateName]);
    

    This is what I had to do to make the compiler happy

提交回复
热议问题