Awaitable<T>
Awaitable<
T> =T|PromiseLike<T>
Represents a value that can be awaited (either the value itself or a Promise-like).
Type Parameters
T: T
The base type.
Since
2.0.0
Example
async function processData(data: `Awaitable<string>`): `Promise<string>` {
const result = await data; // Works with both string and `Promise<string>`
return result.toUpperCase();
}
processData("hello"); // Valid
processData(Promise.resolve("world")); // Valid