Typescript error: TS7053 Element implicitly has an 'any' type

后端 未结 2 1508
走了就别回头了
走了就别回头了 2020-12-10 00:27

this is part of my code:

const myObj: object = {}
const propname = \'propname\'

myObj[propname] = \'string\'
<         


        
2条回答
  •  执笔经年
    2020-12-10 01:18

    Why just simple replace 'object' with 'any':

    const myObj: any = {}
    const propname = 'propname'
    
    myObj[propname] = 'string'
    

    Another short alternative.

提交回复
热议问题