Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
olafurw opened this issue Nov 1, 2023 · 0 comments · Fixed by #7866
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@olafurw
Copy link

olafurw commented Nov 1, 2023

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

@olafurw olafurw added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Nov 1, 2023
@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Nov 1, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants