简体   繁体   English

需要返回类型的箭头 function 的 ESLint 规则

[英]ESLint rule for arrow function requiring return type

I'm having below arrow function in my angular project:我的 angular 项目中有以下箭头 function :

this.httpClient.get('url').subscribe((response)=>{

});

In the above code ESLint should throw an error for not specifying return type.在上面的代码中,ESLint 应该会因为未指定返回类型而引发错误。

Check the rule @typescript-eslint/explicit-function-return-type .检查规则@typescript-eslint/explicit-function-return-type You need to set the option allowTypedFunctionExpressions to false .您需要将选项allowTypedFunctionExpressions设置为false If you are using.eslintrc:如果你使用.eslintrc:

"@typescript-eslint/explicit-function-return-type": [
  "error",
  {
    "allowTypedFunctionExpressions": false
  }
]

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

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