简体   繁体   English

TSLint返回预期的赋值或函数调用

[英]TSLint returns expected an assignment or function call

I am checking my angular project with tslint, and I am getting this error from which I don't understand the reason. 我正在用tslint检查我的Angular项目,但是却收到了我不明白原因的错误。 The error is: expected an assignment or function call 错误是:预期分配或函数调用

getInfoPrinting() {
this.imprimirService.getInfoPrinting().subscribe(
  response => {
    this.loading = false;
    this.printingOrders = response.data;
    this.totalNumberOfCharacters = 0;
    this.totalNumberOfCharactersNext = 0;
    if (this.printingOrders.labelPresentOrder && this.printingOrders.labelPresentOrder.lines) {
      this.printingOrders.labelPresentOrder.lines.forEach(
        line => {
          this.totalNumberOfCharacters += line.length;
        }
      );
    }
    if (this.printingOrders.labelNextOrder && this.printingOrders.labelNextOrder.lines) {
      this.printingOrders.labelNextOrder.lines.forEach(
        line => {
          this.totalNumberOfCharactersNext += line.length;
        }
      );
    }
    if (this.printingOrders.printing) {
      this.suscribeNotifications();
    }
  }
), err => {
  this.loading = false;
  this.alertService.error(INFO_NO_EXISTEN_ORDEN_PREPARADA);
  this.hasAlert = true;
};

} }

The error is in this line: 错误在这一行:

this.imprimirService.getInfoPrinting().subscribe(

What am I doing wrong? 我究竟做错了什么?

Thanks. 谢谢。

Your code is incorrect. 您的代码不正确。 Instead of 代替

getInfoPrinting() {
    this.imprimirService.getInfoPrinting().subscribe(
      response => {
        ...
      }
    ), err => {
      ...
    };
}

It should be 它应该是

getInfoPrinting() {
    this.imprimirService.getInfoPrinting().subscribe(
      response => {
        ...
      }, 
      err => {
      ...
    });
}

The error would be much easier to spot if the method body was shorter. 如果方法主体更短,则错误将更容易发现。 You should delegate to a separate method inside your callback. 您应该在回调中委派一个单独的方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TSLint在分配变量时返回预期的分配或函数调用 - TSLint returns expected an assignment or function call when assigning variables 运行 tslint 时,角度单元测试中的“未使用的表达式,期望赋值或函数调用” - 'unused expression, expected an assignment or function call' in an angular unit test when running tslint 你能在用 typescript/angular 导出它之前创建一个 class 吗? | TSLint:未使用的表达式,需要赋值或 function 调用 - Can you create a class before exporting it in typescript/angular? | TSLint: unused expression, expected an assignment or function call 声纳给出“预期的赋值或函数调用”消息 - Sonar gives 'Expected an assignment or function call' message 未使用的表达式,需要赋值或 function 调用(角度) - Unused expression, expected an assignment or function call (Angular) 预期分配或 function 调用,而是看到一个表达式:no-unused-expressions - Expected an assignment or function call and instead saw an expression: no-unused-expressions 未使用的表达式,期望赋值或函数调用承诺函数中的 Angular lint 错误 - unused expression, expected an assignment or function call Angular lint error in promise function 试图在 Jasmine 中测试 function ,它返回“预期是间谍但得到了一个功能” - Trying to test a function in Jasmine which returns `expected a spy but got a function` 在调用下一个函数之前需要确保函数返回数据 - Need to ensure a function returns data before i call next function $ http.get返回后如何调用函数 - how to call a function on after $http.get returns
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM