Element implicitly has an 'any' type because expression of type 'string' can't be used to index

后端 未结 9 1552
滥情空心
滥情空心 2020-11-27 15:42

Trying out TypeScript for a React project and I\'m stuck on this error:

Element implicitly has an \'any\' type because expression of type \'string\' can\'t b         


        
9条回答
  •  青春惊慌失措
    2020-11-27 16:26

    Thanks to Alex Mckay I had a resolve for dynamic setting a props:

      for(let prop in filter)
          (state.filter as Record)[prop] = filter[prop];
    

提交回复
热议问题