Skip to content

'typedef/arrayDestructuring': impossible to follow this rule in for/of statement #1564

Closed
@TokugawaTakeshi

Description

@TokugawaTakeshi

The rule @typescript-eslint/typedef with arrayDestructuring options tell me to annotate the type inside for/of statement:

image

However, it's impossible in TypeScript:

image

It's required to define the exclusion for for/of (and, I suppose, for/in) statements.

{
  "rules": {
    "@typescript-eslint/typedef": [
      "error",
      {
	  "arrayDestructuring": true,
	  "arrowParameter": true,
	  "memberVariableDeclaration": true,
	  "objectDestructuring": true,
	  "parameter": true,
	  "propertyDeclaration": true,
	  "variableDeclaration": true
	}
    ]
  }
}
const test: { 
  alpha: string, 
  bravo: string 
} = {
  alpha: "foo", 
  bravo: "bar"
};

for (const [ key, value ] of Object.entries(test)) {
  console.log(key);
  console.log(value);
}

What did you expect to happen?

Row for (const [ key, value ] of Object.entries(test)) { does not break the rule 'typedef/arrayDestructuring' because it's impossible to annotate types here in TypeScript.

What actually happened?
It is.

Versions

package version
@typescript-eslint/eslint-plugin 2.19.0 (newest for the moment when I opened this issue)
@typescript-eslint/parser 2.19.0 (newest for the moment when I opened this issue)
@typescript-eslint/typescript-estree 2.19.0
@typescript-eslint/experimental-utils 2.19.0
TypeScript 3.7.5 (newest for the moment when I opened this issue)
node 12.14.1
npm 6.3.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomerspackage: 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