TS循环数组的时候提示Parameter 'item' implicitly has an 'any' type.

2021-07-28 10:16:34

TS循环数组的时候Parameter 'xxx' implicitly has an 'any' type., 出现的原因是你定义的数据没有定义类型 ,隐式具有“any”类型

解决方法

方法一: 显示的定义

const reportWebVitals = item => {
//修改为:
const reportWebVitals = (item : any) => {

方法二: tsconfig.json添加"noImplicitAny": false,或者 “strict”: true,改为false

{
  "compilerOptions": {   
    "target": "ES2018",
    "module": "ESNext",
    "moduleResolution": "Node",
    "strict": false, //<---或者修改这个
    "noImplicitAny": false // <-----
  }
}

关于

联系方式 :

mail: hey_cool@163.com ,
QQ:583459700

备案许可证编号:蜀ICP备16005545号-1 © COPYRIGHT 2015-2024 zhmzjl.com | by: KAPO