Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[explicit-function-return-type] Decorators being reported ESLint: Missing return type on function #2842

Closed
3 tasks done
abrarazeem opened this issue Dec 3, 2020 · 1 comment
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin working as intended Issues that are closed as they are working as intended

Comments

@abrarazeem
Copy link

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
      "@typescript-eslint/explicit-function-return-type": ["error", {
      allowExpressions: true
    }]
  }
}
import { Controller, HttpCode, HttpStatus } from '@nestjs/common'
import { AppService } from './app.service'
// Actually it's imported from @nestjs/common package but for the sake of testing and quick glimpse adding here.
export declare const Get: (path?: string | string[]) => MethodDecorator

@Controller()
export class AppController {

  constructor(private readonly appService: AppService) {}

  @Get() // ESLint: Missing return type on function.(@typescript-eslint/explicit-function-return-type)
  @HttpCode(HttpStatus.OK)
  getHello() {

    return this.appService.getHello()
  }
}

Expected Result
Decorators shouldn't be reported as missing return type.

Actual Result

Missing return type on function.eslint@typescript-eslint/explicit-function-return-type

Versions

package version
@typescript-eslint/eslint-plugin 4.9.0
@typescript-eslint/parser 4.9.0
TypeScript 4.1.2
ESLint 7.14.0
node 14.15.1
@abrarazeem abrarazeem added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Dec 3, 2020
@bradzacher bradzacher added working as intended Issues that are closed as they are working as intended and removed triage Waiting for maintainers to take a look labels Dec 3, 2020
@bradzacher
Copy link
Member

bradzacher commented Dec 3, 2020

image

The error is higlighting the start of the function, not the decorator itself.

getHello has no return type.

ota-meshi pushed a commit to ota-meshi/typescript-eslint that referenced this issue Dec 4, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin working as intended Issues that are closed as they are working as intended
Projects
None yet
Development

No branches or pull requests

2 participants