具体场景为ts中类型为 "string" 的表达式不能用于索引类型 "{}"。

 

 

在我们编写ts代码的时候会出现波浪线警告,鼠标移上去出现以下情况:

 (property) DateHelper.prmimaryKey: string
 元素隐式具有 "any" 类型,因为类型为 "string" 的表达式不能用于索引类型 "{}"。
 在类型 "{}" 上找不到具有类型为 "string" 的参数的索引签名。ts(7053)
 速览问题 (Alt+F8)       没有可用的快速修复

我们在项目中的tsconfig.json文件中添加:

 "suppressImplicitAnyIndexErrors":true,
  • 1

则不报警告了
ts中类型为 "string" 的表达式不能用于索引类型 "{}"。

相关文章:

  • 2021-05-26
  • 2021-08-08
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-07-26
  • 2021-11-05
  • 2022-12-23
相关资源
相似解决方案