Skip to content

[@typescript-eslint/typedef] variableDeclaration broken with for..of loops #783

@octogonz

Description

@octogonz

Repro

{
  "rules": {
    "@typescript-eslint/typedef": [
      "error",
      {
        "variableDeclaration": true
      },
    ],
  }
}
// error @typescript-eslint/typedef : expected item to have a type annotation
for (const item of ['a', 'b']) {
}

Expected Result

The error should not be reported for a for..of loop variable.

Actual Result

The error is reported. The error is impossible to fix, because TypeScript does not allow type annotations here.

Additional Info

TSLint encountered this same problem as palantir/tslint#743.

Their fix is here and might be relevant: palantir/tslint#745

Versions

package version
@typescript-eslint/eslint-plugin 2.0.0-alpha.4
@typescript-eslint/parser 1.13.0
TypeScript 3.5.3
ESLint 6.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershas prthere is a PR raised to close thispackage: 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