This rule disallows awaiting a value that is not a "Thenable" (an object which has
then method, such as a Promise).
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.
Examples of code for this rule:
- ❌ Incorrect
- ✅ Correct
const createValue = () => 'value';
const createValue = async () => 'value';
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.
- TSLint: 'await-promise'
- ✅ Recommended
- 🔧 Fixable
- 💭 Requires type information