Skip to content

Bug: [@typescript-eslint/require-await] No await expression error with "await using" #7865

Closed
@olafurw

Description

@olafurw

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.2.2&fileType=.tsx&code=MYGwhgzhAEAqCmEAuBhcVoEsC2AHE828AdkjAIIQCexwAIphLgPYRgBGB0A3gFDTQkiJAC5oyAE6ZiAcwDc-aMGbFJAV2BJmEgBQBKHooFIAFowB0Q5NAC80AEQn4IEM2gB3bSAAm9hQIBfXkVIGmBoAG0AZSpsdmYQc1DaBiZWeABdfTEABQlmbEZ4AB4AN2ZMbwA%2BQwEBAHp66AApNWsIAvhoMHcwTCQjbt7%2B6GJ4d2g8gqKdHQlEBNL4AxsaiHgkWBx4ZjUkOYWQJYAaaABGAAY9PX9oIKDeZVUkaAAzYltu6lpofVsavgCHp9F5taQyQTCT5jCYIZBoSAQfQKRSNaAoApEUjQIjQXYvLTieBdUxdeASfISaAyNzAqio%2BrAkYwyb5QrrWbzDpHZb-Imbbb4g7ck7nK43XgBIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEI0QR1gEtpEBaAQwHdzCAXdKAewDNnIAacbSAAVoE8ADigDG0QoNqkU8QgDtaAehIFiZKjXoZIiaNEbRIXAL4hjQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

class TestClass implements AsyncDisposable {
  test: string;
  constructor() {
    this.test = "hello world";
  }

  async [Symbol.asyncDispose](): Promise<void> {
    // Just some await
    await new Promise((resolve) => setTimeout(resolve, 10));
  }
}

const fn = async () => {
  // Async arrow function 'fn' has no 'await' expression.
  // Even with await using
  await using test = new TestClass();

  // Comment me out to see the error go away
  //await new Promise((resolve) => setTimeout(resolve, 10));
}


### ESLint Config

```javascript
module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "require-await": "off",
    "@typescript-eslint/require-await": "error"
  },
};

tsconfig

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

Expected Result

No error to be shown

Actual Result

Error: Async arrow function 'fn' has no 'await' expression. 13:21 - 13:23

When the variable I'm using does have an await expression and it's asyncDisposable function needs await.

Additional Info

No response

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