{"id":"6f62416b1376af9e","repo":"sindresorhus/is","slug":"expected-value-which-is-int32array-received-val","errorCode":null,"errorMessage":"Expected value which is `Int32Array`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `Int32Array`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1683,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('infinite number', value));\n\t}\n}\n\nexport function assertInRange(value: number, range: number | [number, number], message?: string): asserts value is number {\n\tif (!isInRange(value, range)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('in range', value));\n\t}\n}\n\nexport function assertInt16Array(value: unknown, message?: string): asserts value is Int16Array {\n\tif (!isInt16Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Int16Array', value));\n\t}\n}\n\nexport function assertInt32Array(value: unknown, message?: string): asserts value is Int32Array {\n\tif (!isInt32Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Int32Array', value));\n\t}\n}\n\nexport function assertInt8Array(value: unknown, message?: string): asserts value is Int8Array {\n\tif (!isInt8Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Int8Array', value));\n\t}\n}\n\nexport function assertInteger(value: unknown, message?: string): asserts value is number {\n\tif (!isInteger(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('integer', value));\n\t}\n}\n\nexport function assertIterable<T = unknown>(value: unknown, message?: string): asserts value is Iterable<T> {\n\tif (!isIterable(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Iterable', value));","sourceCodeStart":1665,"sourceCodeEnd":1701,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1665-L1701","documentation":"Thrown by `assertInt32Array()` (source/index.ts:1681) when the value fails `isInt32Array()`, which checks the internal object type tag via `getObjectType(value) === 'Int32Array'`. The library uses assert functions to fail fast with a TypeError that names the actual received type instead of letting bad data propagate.","triggerScenarios":"Calling `assertInt32Array(value)` with anything that isn't a real Int32Array: a plain Array of numbers, an ArrayBuffer, a Buffer/Uint8Array, an Int32Array from another mechanism that lost its type tag, or null/undefined.","commonSituations":"Passing a plain `[1,2,3]` array where binary APIs (WebGL, WASM, audio) need typed arrays; deserializing JSON (typed arrays become plain objects/arrays); passing an ArrayBuffer without wrapping it; cross-realm typed arrays are handled since the check uses the toString tag, so this is rarely a realm issue.","solutions":["Wrap the data before asserting: `new Int32Array(plainArray)` or `new Int32Array(arrayBuffer)`.","If the value comes from JSON or structured serialization, reconstruct the typed array after parsing.","If any typed array is acceptable, use `assertTypedArray()` instead of the Int32Array-specific assert."],"exampleFix":"// before\nconst data = [1, 2, 3];\nassertInt32Array(data); // throws\n// after\nconst data = new Int32Array([1, 2, 3]);\nassertInt32Array(data);","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Int32Array)) {\n  value = new Int32Array(value); // or handle explicitly\n}","typeGuard":"const isInt32Array = (v: unknown): v is Int32Array => v instanceof Int32Array;","tryCatchPattern":null,"preventionTips":["Check with is.int32Array(value) before calling assert.int32Array","Don't confuse Int32Array with Int8Array/Uint32Array or plain number[] — instanceof checks the exact typed-array class","When data crosses realms (iframes/workers), instanceof can fail; use ArrayBuffer.isView plus constructor name checks or structuredClone into the local realm"],"tags":["typed-array","type-assertion","typescript"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}