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