Home > Back-end >  ESLint rule for arrow function requiring return type
ESLint rule for arrow function requiring return type

Time:12-02

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.

CodePudding user response:

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
  }
]
  • Related