简体   繁体   English

TSLint在分配变量时返回预期的分配或函数调用

[英]TSLint returns expected an assignment or function call when assigning variables

I am using tslint to check my angular 2 project and am getting some errors that I don't really understand. 我正在使用tslint检查我的angular 2项目,但遇到了一些我不太了解的错误。 The following code snippit gets a "expected an assignment or function call"-error, but isn't that exactly what my code is doing? 以下代码段收到“预期的分配或函数调用”错误,但这不是我的代码正在做什么吗?

getUsers() {
    this._userService.getUsers().subscribe(data => {
        this.userList = data.users,
        this.number_of_pages = data.number_of_pages,
        this.number_of_users = data.number_of_users;
    });
}

Is this a bug or do I not understand the error correctly? 这是错误还是我无法正确理解错误? I am using typescript version 1.8.10. 我正在使用打字稿版本1.8.10。

Edit: The error occures at the first assignment, so this.userList = data.users 编辑:错误发生在第一次分配,因此this.userList = data.users

I think the problem is that you don't use semi-colons but comma at the end of two lines: 我认为问题在于您没有使用分号,而是在两行的末尾使用逗号:

this.userList = data.users, // <----
this.number_of_pages = data.number_of_pages, // <----
this.number_of_users = data.number_of_users;

You should use the following: 您应该使用以下内容:

this.userList = data.users; // <----
this.number_of_pages = data.number_of_pages; // <----
this.number_of_users = data.number_of_users;

暂无
暂无

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

相关问题 TSLint返回预期的赋值或函数调用 - TSLint returns expected an assignment or function call 运行 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 期望一个赋值或函数调用,而是在定义接口时看到一个表达式 - Expected an assignment or function call and instead saw an expression when defining interface 声纳给出“预期的赋值或函数调用”消息 - Sonar gives 'Expected an assignment or function call' message 未使用的表达式,预期的赋值或函数调用 - unused expression, expected an assignment or function call 未使用的表达式,需要赋值或 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 三元运算符:需要赋值或函数调用,而看到的是表达式 - Ternary operator: Expected an assignment or function call and instead saw an expression React-Typescript:预期分配或 function 调用,而是看到一个表达式 - React-Typescript: Expected an assignment or function call and instead saw an expression
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM