tslint错误:预期分配或函数调用

时间:2018-05-10 18:18:36

标签: typescript

使用代码

if (lstChildItem.cashDrawer == lstCshItems) {
  if (parseFloat(lstChildItem.currentBalance) != 0) {
    brName.indexOf(this.commonService.getBoroughs(lstItem.borough)[0].value) === -1 
      ? brName.push(this.commonService.getBoroughs(lstItem.borough)[0].value) 
      : '';
    trace[0].currBlnc.push(lstChildItem.currentBalance);
    currBalance = currBalance + parseFloat(lstChildItem.currentBalance);
    trace[0].frmName.push(this.formatCur(lstChildItem.currentBalance));
    trace[0].frmCurrBlnc.push(this.formatValue(lstChildItem.currentBalance));
  }
}

获取错误:

tslint error :[438, 29]: expected an assignment or function call

1 个答案:

答案 0 :(得分:0)

这不是TypeScript错误,它是一个tslint错误(显然是?:D)。

brName.indexOf(this.commonService.getBoroughs(lstItem.borough)[0].value) === -1 
      ? brName.push(this.commonService.getBoroughs(lstItem.borough)[0].value) 
      : '';

是“禁止操作” - 您可以disable that rule或将其更改为

if (brName.indexOf(this.commonService.getBoroughs(lstItem.borough)[0].value) === -1) {
  brName.push(this.commonService.getBoroughs(lstItem.borough)
}