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

[@typescript-eslint/typedef] In the class, even if there are types, there will still check not passed #4033

Closed
3 tasks done
duan602728596 opened this issue Oct 20, 2021 · 4 comments · Fixed by #4034 · 4 remaining pull requests
Closed
3 tasks done

[@typescript-eslint/typedef] In the class, even if there are types, there will still check not passed #4033

duan602728596 opened this issue Oct 20, 2021 · 4 comments · Fixed by #4034 · 4 remaining pull requests
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@duan602728596
Copy link

duan602728596 commented Oct 20, 2021

  • 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/typedef": [
      "error",
      {
        "arrayDestructuring": true,
        "arrowParameter": true,
        "memberVariableDeclaration": true,
        "objectDestructuring": true,
        "parameter": true,
        "propertyDeclaration": true,
        "variableDeclaration": true
      }
    ]
  }
}
class ClassName {
  public str: string = 'str';
  #num: number = 13;

  func: () => void = (): void => {
    console.log(this.str);
  };
}

Expected Result

Eslint check passed.

Actual Result

Line 2:
ESLint: Expected str to have a type annotation.(@typescript-eslint/typedef).
Line 3:
ESLint: Expected a type annotation.(@typescript-eslint/typedef).
Line 5:
ESLint: Expected func to have a type annotation.(@typescript-eslint/typedef).

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 5.1.0
@typescript-eslint/parser 5.1.0
TypeScript 4.4.4
ESLint 8.0.1
node 16.11.1
@duan602728596 duan602728596 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Oct 20, 2021
@bradzacher
Copy link
Member

I am unable to reproduce this against master.

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party unable to repro issues that a maintainer was not able to reproduce and removed triage Waiting for maintainers to take a look labels Oct 20, 2021
@duan602728596
Copy link
Author

duan602728596 commented Oct 20, 2021

This is the address of a demo: https://github.com/duan602728596/eslint-ts-typedef-bug

This code passed the test. However, if you use idea or use command to check, there will be errors.

  2:3  error  Expected str to have a type annotation   @typescript-eslint/typedef
  3:3  error  Expected a type annotation               @typescript-eslint/typedef
  5:3  error  Expected func to have a type annotation  @typescript-eslint/typedef

@bradzacher bradzacher added bug Something isn't working and removed awaiting response Issues waiting for a reply from the OP or another party unable to repro issues that a maintainer was not able to reproduce labels Oct 20, 2021
@bradzacher
Copy link
Member

bradzacher commented Oct 20, 2021

@Shinigami92
Copy link

Tested 5.1.1-alpha.6, it works 🎉

CatsMiaow added a commit to CatsMiaow/eslint-config that referenced this issue Oct 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.