Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug: [promise-function-async] fixer generates invalid syntax with override keyword #11729

@sushichan044

Description

@sushichan044

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.9.3&fileType=.ts&code=MYGwhgzhAEBCkFNoG8BQ1qQJ4DtjQDMB7IgCgEoV0NoAnBAFwFdadoAFWogWwEsIEAOnoQiIAG4JSAFgBM5ANzUAvqlWpQkGABEEtXpIAm0BAA8GCHIZjwBVDEUm19hpMTKU0NOoxZtOPPxCImKSpLIADFHkKmpAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Y6AewFtLlFaAM1hMy%2BSpya0AhskKj0URNC7RI4MAF8QmoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

class Base {
  async foo() {
    return Promise.resolve(42);
  }
}

class Derived extends Base {
  override foo() {
    return Promise.resolve(2000)
  }
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/promise-function-async": "error"
  }
};

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

The fixer should produce valid TypeScript syntax with the async keyword placed after the override modifier, following TypeScript's correct modifier order.

class Base {
  async foo() {
    return Promise.resolve(42);
  }
}

class Derived extends Base {
  override async foo() {
    return Promise.resolve(2000)
  }
}

Actual Result

The fixer generates invalid syntax by placing the async keyword before the override modifier, which violates TypeScript's modifier ordering rules and causes a syntax error.

class Base {
  async foo() {
    return Promise.resolve(42);
  }
}

class Derived extends Base {
  async override foo() {
    return Promise.resolve(2000)
  }
}

Additional Info

The root cause is that the fixer's token-skipping logic only handles Keyword type tokens such as public and static, but TypeScript's override is classified as an Identifier token.
This causes the insertion point to be calculated incorrectly, resulting in invalid modifier ordering.

Metadata

Metadata

Assignees

No one assigned

    Labels

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