思否标题不能超过 64 个有效字符 emm...
完整标题是
《
React element implicitly has an 'any' type because expression of type 'string' can't be used to index type 告警解决
》
目前我遇到两种情况会出现这个告警
情景一:
keyToNameMap[keyItem]
解决办法:
给keyToNameMap的key和value加上类型限制,如下图
加上 { [key: string]: string }
情景二:
同样的keyToNameMap[keyItem]
但这里的map (contentInfo)不是定义的常量。contentInfo由useState创建,受type ContentInfo限制。
解决办法:
给type ContentInfo加上类型限制,如下图
加上 [key: string]: string | number;
完结
同步更新到自己的语雀
https://www.yuque.com/diracke...
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。