简体   繁体   English

这个箭头函数体可以通过省略大括号和关键字'return'来简化。tslint(arrow-return-shorthand)

[英]This arrow function body can be simplified by omitting the curly braces and the keyword 'return'.tslint(arrow-return-shorthand)

My purpose is read a file json with all name of my input's project我的目的是读取一个文件 json,其中包含我输入项目的所有名称

{ 'home':'home'}:

and I create the service but I do this:我创建了服务,但我这样做:

getPropertiesName(): Observable<Object> {
    return this.http.get('assets/config/propertiesName.json').pipe(map((response: Response) => {  return response.json(); }));
  }

The problem is that the compiler gives me this error:问题是编译器给了我这个错误:

This arrow function body can be simplified by omitting the curly braces and the keyword 'return'.tslint(arrow-return-shorthand)

Anyone can help me to resolve this?任何人都可以帮我解决这个问题吗?

adsds it's the same adsds 是一样的

this.http.get(...).pipe(map((response: Response) => {  return response.json(); }));

than

this.http.get(...).pipe(map((response: Response) => response.json();));

BTW, your response is yet a json, has no sense convert to json顺便说一句,您的响应还不是一个 json,转换为 json 没有任何意义

This is a lint error from tslint, and is likely auto fixable.这是来自 tslint 的 lint 错误,并且可能会自动修复。 Try running:尝试运行:

ng lint --fix

And then consider the diff in conjunction with the error message you posted.然后结合您发布的错误消息考虑差异。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM