Type guard to check if a value is a Promise or Promise-like (thenable).
Checks both for instanceof Promise and for objects with then/catch/finally methods, allowing it to work with Promise-like objects from different execution contexts.
The Promise type
The resolved value type
The value to check
True if the value is a Promise or thenable
const value: unknown = fetchData();if (isPromise(value)) { const result = await value;} Copy
const value: unknown = fetchData();if (isPromise(value)) { const result = await value;}
Type guard to check if a value is a Promise or Promise-like (thenable).
Checks both for instanceof Promise and for objects with then/catch/finally methods, allowing it to work with Promise-like objects from different execution contexts.