Skip to content

Bug: [no-confusing-void-expression] ignoreVoidReturningFunctions ignores generic type returning functions #10289

Closed as not planned
@phaux

Description

@phaux

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://deploy-preview-10067--typescript-eslint.netlify.app/play/#ts=5.5.2&fileType=.ts&code=GYVwdgxgLglg9mABAgogJzXNAeAKgPgAoIBDAGzICMSIBrALkUIEpEBefRXZxgNzhgATRAG8AUIkSkK1OiwDcYgL5ixqDFkIt2nCAgDOcMgFMAdGTgBzQgHI4cAA76bzZorF6w%2BqIgftEAAqYALYw%2BmZoxoZkvMaEAIzMplAAFsZgWqwcUgZGZhbWrmJAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1rI6YDNYyZgHNaANw6UAJvQAexaCiG90YANrhsORNGgdokADSatWLdkiVhnRQDVJUgEqJ8saExEAxWEzL5KvKgY%2BHCIJtgAvuEAuppREUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

declare function onError<T>(callback: () => T): void;

onError(() => console.log('oops'));

Promise.resolve(1).then(() => console.log("foo"))

ESLint Config

{
  "rules": {
    "@typescript-eslint/no-confusing-void-expression": [
      "error",
      {
        "ignoreVoidReturningFunctions": true
      }
    ]
  }
}

tsconfig

No response

Expected Result

Should report both console.logs

The correct code should be

onError((): void => console.log('oops'));

Promise.resolve(1).then((): void => console.log("foo"))

or

onError<void>(() => console.log('oops'));

Promise.resolve(1).then<void>(() => console.log("foo"))

Actual Result

Doesn't report.

Additional Info

Continued from #8538

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions