为什么我会收到这个错误?
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ 0: string; 1: string; 2: string; 3: string; }'.
No index signature with a parameter of type 'string' was found on type '{ 0: string; 1: string; 2: string; 3: string; }'.ts(7053)
这是我的代码:我专门将索引设为字符串,所以应该没有问题,但是我的 StatusMap 变量给了我这个红旗..
const getStatusMeaning = (index: string) => {
const StatusMap = {
'0': 'Unknown',
'1': 'Pending',
'2': 'Success',
'3': 'Failure',
}
return StatusMap[index]
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句