使用流类型检查器键入提示我的JavaScript代码
const functionName = (name: string, newvalue:string , units: {}) :{} => {
//Obj to be returned
const returnObj = {};
//index of a event.target.
const indexofChange: number = units.findIndex(matchElement, {
name: name
});
....
....
}
流程给我一个错误
由于对象类型[1]中缺少属性findIndex,因此无法调用units.findIndex。
答案 0 :(得分:0)
感谢@Tholle
const functionName = (name: string, newvalue:string , units: Array<Object>) :Array<Object> => {
//Array to be returned
const returnArray:Array<Object> = [];
//index of a event.target.
const indexofChange: number = units.findIndex(matchElement, {
name: name
});
....
....
}
解决此问题