Skip to main content

await-thenable

Disallows awaiting a value that is not a Thenable.

This rule disallows awaiting a value that is not a "Thenable" (an object which has then method, such as a Promise). While it is valid JavaScript to await a non-Promise-like value (it will resolve immediately), this pattern is often a programmer error, such as forgetting to add parenthesis to call a function that returns a Promise.

Attributes

  • Included in configs
    • ✅ Recommended
    • 🔒 Strict
  • Fixable
    • 🔧 Automated Fixer
    • 🛠 Suggestion Fixer
  • 💭 Requires type information

Rule Details

Examples of code for this rule:

await 'value';

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

Options

// .eslintrc.json
{
"rules": {
"@typescript-eslint/await-thenable": "error"
}
}

This rule is not configurable.

When Not To Use It

If you want to allow code to await non-Promise values. This is generally not preferred, but can sometimes be useful for visual consistency.