{"id":"c64db92254ff5bcf","repo":"sindresorhus/is","slug":"expected-value-which-is-native-promise-received","errorCode":null,"errorMessage":"Expected value which is `native Promise`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `native Promise`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1719,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('Iterable', value));\n\t}\n}\n\nexport function assertMap<Key = unknown, Value = unknown>(value: unknown, message?: string): asserts value is Map<Key, Value> {\n\tif (!isMap(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Map', value));\n\t}\n}\n\nexport function assertNan(value: unknown, message?: string): asserts value is number {\n\tif (!isNan(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('NaN', value));\n\t}\n}\n\nexport function assertNativePromise<T = unknown>(value: unknown, message?: string): asserts value is Promise<T> {\n\tif (!isNativePromise(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('native Promise', value));\n\t}\n}\n\nexport function assertNegativeInteger(value: unknown, message?: string): asserts value is number {\n\tif (!isNegativeInteger(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('negative integer', value));\n\t}\n}\n\nexport function assertNegativeNumber(value: unknown, message?: string): asserts value is number {\n\tif (!isNegativeNumber(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('negative number', value));\n\t}\n}\n\nexport function assertNodeStream(value: unknown, message?: string): asserts value is NodeStream {\n\tif (!isNodeStream(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Node.js Stream', value));","sourceCodeStart":1701,"sourceCodeEnd":1737,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1701-L1737","documentation":"Thrown by `assertNativePromise()` (source/index.ts:1717) when the object type tag isn't exactly 'Promise'. Thenables and third-party promise implementations (Bluebird, Q, jQuery Deferred) fail even though they are awaitable, because this assert demands a native Promise instance specifically.","triggerScenarios":"Calling `assertNativePromise()` with a custom thenable (`{then() {...}}`), a Bluebird/Q promise, a synchronous return value from a function you expected to be async, or an async function itself rather than its invocation result.","commonSituations":"Libraries or older codebases returning Bluebird promises; mocks/stubs in tests returning plain thenables; forgetting to call the async function (`fn` vs `fn()`); polyfilled environments where Promise is replaced by a non-native implementation.","solutions":["Normalize to a native promise before asserting: `Promise.resolve(thenable)` always returns a native Promise.","If any awaitable is fine, use the looser `assertPromise()` (accepts thenables) instead of `assertNativePromise()`.","Make sure you pass the result of calling the async function, not the function reference: `assertNativePromise(fn())`."],"exampleFix":"// before\nconst result = bluebirdApi.fetch();\nassertNativePromise(result); // throws — Bluebird promise\n// after\nconst result = Promise.resolve(bluebirdApi.fetch());\nassertNativePromise(result);","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Promise)) {\n  value = Promise.resolve(value); // wraps thenables and plain values into a native Promise\n}","typeGuard":"const isNativePromise = (v: unknown): v is Promise<unknown> => v instanceof Promise;","tryCatchPattern":null,"preventionTips":["Thenables from Bluebird, jQuery, or ORMs are not native Promises — normalize with Promise.resolve(thenable)","async functions always return native Promises; plain functions returning custom thenables do not","If you only need awaitability, check for a .then function (is.promise semantics) instead of asserting nativeness"],"tags":["promise","async","type-assertion"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}