persona-community-5/.pnpm-store/v3/files/27/a9756e5278ee2d88c8ec54703d3106a97dd5bc14d2741a592995552b72c88b6b32dcc517e2588b2a424198d324cfa7422e315422c427e779a8e9f6aba3f814
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

49 lines
1.5 KiB
Plaintext

---
description: 'Disallow awaiting a value that is not a Thenable.'
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/await-thenable** for documentation.
A "Thenable" value is an object which has a `then` method, such as a Promise.
The `await` keyword is generally used to retrieve the result of calling a Thenable's `then` method.
If the `await` keyword is used on a value that is not a Thenable, the value is directly resolved immediately.
While doing so is valid JavaScript, it is often a programmer error, such as forgetting to add parenthesis to call a function that returns a Promise.
## Examples
<Tabs>
<TabItem value="❌ Incorrect">
```ts
await 'value';
const createValue = () => 'value';
await createValue();
```
</TabItem>
<TabItem value="✅ Correct">
```ts
await Promise.resolve('value');
const createValue = async () => 'value';
await createValue();
```
</TabItem>
</Tabs>
## When Not To Use It
If you want to allow code to `await` non-Promise values.
For example, if your framework is in transition from one style of asynchronous code to another, it may be useful to include `await`s unnecessarily.
This is generally not preferred but can sometimes be useful for visual consistency.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.