Skip to content

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

@duan602728596

Description

@duan602728596
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions