{"id":"a9c191be3f7b6926","repo":"sindresorhus/is","slug":"expected-value-which-is-promise-received-value","errorCode":null,"errorMessage":"Expected value which is `Promise`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `Promise`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1860,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('positive integer', value));\n\t}\n}\n\nexport function assertPositiveNumber(value: unknown, message?: string): asserts value is number {\n\tif (!isPositiveNumber(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('positive number', value));\n\t}\n}\n\nexport function assertPrimitive(value: unknown, message?: string): asserts value is Primitive {\n\tif (!isPrimitive(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('primitive', value));\n\t}\n}\n\nexport function assertPromise<T = unknown>(value: unknown, message?: string): asserts value is Promise<T> {\n\tif (!isPromise(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Promise', value));\n\t}\n}\n\nexport function assertPropertyKey(value: unknown, message?: string): asserts value is PropertyKey {\n\tif (!isPropertyKey(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('PropertyKey', value));\n\t}\n}\n\nexport function assertRegExp(value: unknown, message?: string): asserts value is RegExp {\n\tif (!isRegExp(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('RegExp', value));\n\t}\n}\n\nexport function assertSafeInteger(value: unknown, message?: string): asserts value is number {\n\tif (!isSafeInteger(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('safe integer', value));","sourceCodeStart":1842,"sourceCodeEnd":1878,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1842-L1878","documentation":"Thrown by `assert.promise()` when the value is not a Promise. `isPromise` checks for a native Promise or a thenable-shaped object; plain values, resolved results, and functions that return promises (but weren't called) all fail. It narrows to `Promise<T>` so the value can be safely awaited or chained.","triggerScenarios":"Calling `assert.promise(value)` with the already-awaited result of a promise, an async function reference that was never invoked (`fn` instead of `fn()`), a synchronous function's return value, or a callback-style API result.","commonSituations":"Refactoring an async function to synchronous (or vice versa) without updating callers; forgetting the parentheses on an async call; awaiting too early so the assert receives the resolved value; mixing callback and promise APIs (e.g. a library version change from callbacks to promises or back).","solutions":["Invoke the async function instead of passing its reference: `assert.promise(fetchData())`, not `assert.promise(fetchData)`.","Remove a premature `await` if the assert is meant to receive the pending promise itself.","If the producer became synchronous, wrap with `Promise.resolve(value)` or update the contract so the assert is no longer needed.","Promisify callback-style APIs with `util.promisify` before asserting."],"exampleFix":"// before\nconst data = await fetchData();\nassert.promise(data); // throws: received the resolved value's type\n// after\nconst pending = fetchData();\nassert.promise(pending);\nconst data = await pending;","handlingStrategy":"type-guard","validationCode":"if (value == null || typeof value.then !== 'function') {\n  throw new TypeError('Expected a Promise/thenable');\n}","typeGuard":"function isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n  return value != null && typeof (value as any).then === 'function';\n}","tryCatchPattern":"try {\n  ow(value, ow.promise);\n} catch (error) {\n  if (error instanceof ArgumentError) {\n    throw new TypeError(`Expected a Promise: ${error.message}`);\n  }\n  throw error;\n}","preventionTips":["Calling an async function returns a Promise; passing the function itself does not — pass fn(), not fn","A forgotten await upstream can hand you a resolved value instead of the Promise the API wants — wrap with Promise.resolve(value) when unsure","Thenables from other libraries may pass duck-typing but not instanceof Promise; prefer duck-typed checks","Enable @typescript-eslint/no-misused-promises and no-floating-promises to catch these statically"],"tags":["type-check","assertion","promise","async"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}