【问题标题】:ESLint rule for arrow function requiring return type需要返回类型的箭头函数的 ESLint 规则
【发布时间】:2022-01-08 04:19:23
【问题描述】:

我的 Angular 项目中有以下箭头功能:

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

});

在上面的代码中,ESLint 应该会因为没有指定返回类型而抛出错误。

【问题讨论】:

    标签: angular typescript eslint eslintrc typescript-eslint


    【解决方案1】:

    检查规则@typescript-eslint/explicit-function-return-type。您需要将选项allowTypedFunctionExpressions 设置为false。如果您使用的是 .eslintrc:

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

    【讨论】:

    • 非常感谢。它奏效了。
    猜你喜欢
    • 2023-02-04
    • 1970-01-01
    • 2020-07-30
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    • 2017-09-13
    相关资源
    最近更新 更多