Search code examples
angulartypescripteslinteslintrctypescript-eslint

ESLint rule for arrow function requiring return type


I'm having below arrow function in my angular project:

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

});

In the above code ESLint should throw an error for not specifying return type.


Solution

  • Check the rule @typescript-eslint/explicit-function-return-type. You need to set the option allowTypedFunctionExpressions to false. If you are using .eslintrc:

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