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

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

this is part of my code:

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

myObj[propname] = \'string\'
<         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 01:02

    You have to define what kind of index type the object has. In your case it is a string based index.

    const myObj: {[index: string]:any} = {}
    

提交回复
热议问题