Skip to content

Bug: [no-misused-promises] should not report static accessor properties with a function initializer #10812

Closed
@ronami

Description

@ronami

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://typescript-eslint.io/play/#ts=5.5.2&fileType=.tsx&code=MYGwhgzhAEBCkFMCM0DeBYAUNaAHArgEYgCWw0EA9gLYICyCALgBaUAm0AvNABQCUALmgA3SiQ6cAfGmgBfLPMxZQkGAFEAHowQA7NgjYoEW3WxjwIyNFhwB6W9GCUATs4TBGIAJ7Q2lBBA6AOSM0G64Low2eESk5BCMYIxkFDT0TKwS0JBeOuT8QgAKzjQklgA8ouLSUjKKisrgUHCIAEzW2DHEKVS0DCzsXLyCImIS0qhyCliNqtCa2noG7caLZi2W7Rid9mEIEc6MMIT4oRCs%2BCBswVGdBN3xicnkYMDAAVTOqX0Zg9w5eWGRRK1DKCEqYxqEymmEUQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oFtLlZkiACa1i0Dr0GoMkRNHHRI4MAF8QKoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

class Base1 {
  public someMethod = (): void => { }
}

class Extended1 extends Base1 {
  // correctly doesn't report
  public static someMethod = async (): Promise<void> => { }
}

class Base2 {
  public someMethod = (): void => { }
}

class Extended2 extends Base2 {
  // reports but shouldn't
  public static accessor someMethod = async (): Promise<void> => { }
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/no-misused-promises": "error",
  },
};

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

I expected the rule not to report this, similar to how it treats standard static properties.

Actual Result

The rule reported the static accessor property, which I think is a false-positive.

Additional Info

Related: #10763 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked 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-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions