---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: useAwaitThenable
description: Learn more about useAwaitThenable
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="JavaScript (and super languages)" icon="seti:javascript">
:::caution
This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time.
:::
:::note
This rule belongs to the project domain. This means that its activation will activate the Biome Scanner, which might affect the performance. Read more about it in the [documentation page](/linter/domains#project)
:::
## Summary
- Rule available since: `v2.3.9`
- Diagnostic Category: [`lint/nursery/useAwaitThenable`](/reference/diagnostics#diagnostic-category)
- This rule doesn't have a fix.
- The default severity of this rule is [**information**](/reference/diagnostics#information).
- This rule belongs to the following domains:
  - [`project`](/linter/domains#project)
- Sources: 
  - Inspired from [`@typescript-eslint/use-await-thenable`](https://typescript-eslint.io/rules/use-await-thenable)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"nursery": {
				"useAwaitThenable": "error"
			}
		}
	}
}

```
## Description
Enforce that `await` is _only_ used on `Promise` values.

:::caution
At the moment, this rule only checks for instances of the global
`Promise` class. This is a major shortcoming compared to the ESLint
rule if you are using custom `Promise`-like implementations such as
[Bluebird](http://bluebirdjs.com/) or in-house solutions.
:::

## Examples

### Invalid

```js title='invalid-primitive.js'
await 'value';
```

<pre class="language-text"><code class="language-text"><a href="file:///invalid-primitive.js">/invalid-primitive.js</a>:1:1 <a href="https://biomejs.dev/linter/rules/use-await-thenable">lint/nursery/useAwaitThenable</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">&#96;await&#96; used on a non-Promise value.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>await 'value';<br />   <strong>   │ </strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This may happen if you accidentally used &#96;await&#96; on a synchronous value.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Please ensure the value is not a custom &quot;thenable&quot; implementation before removing the &#96;await&#96;: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global&#95;Objects/Promise#thenables</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit </span><span style="color: lightgreen;"><a href="https://biomejs.dev/linter/#nursery">https://biomejs.dev/linter/#nursery</a></span><span style="color: lightgreen;"> for more information.</span><br />  <br /></code></pre>

```js title='invalid-function-call.js'
const createValue = () => 'value';
await createValue();
```

<pre class="language-text"><code class="language-text"><a href="file:///invalid-function-call.js">/invalid-function-call.js</a>:2:1 <a href="https://biomejs.dev/linter/rules/use-await-thenable">lint/nursery/useAwaitThenable</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">&#96;await&#96; used on a non-Promise value.</span><br />  <br />    <strong>1 │ </strong>const createValue = () =&gt; 'value';<br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong>await createValue();<br />   <strong>   │ </strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>3 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This may happen if you accidentally used &#96;await&#96; on a synchronous value.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Please ensure the value is not a custom &quot;thenable&quot; implementation before removing the &#96;await&#96;: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global&#95;Objects/Promise#thenables</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit </span><span style="color: lightgreen;"><a href="https://biomejs.dev/linter/#nursery">https://biomejs.dev/linter/#nursery</a></span><span style="color: lightgreen;"> for more information.</span><br />  <br /></code></pre>

### Valid

```js title='valid-examples.js'
await Promise.resolve('value');

const createValue = async () => 'value';
await createValue();
```

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/src/lint/nursery/use_await_thenable.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/tests/specs/nursery/useAwaitThenable)

</TabItem>
</Tabs>