{"id":"a310bb87972c8234","repo":"sindresorhus/is","slug":"expected-value-which-is-float32array-received-v","errorCode":null,"errorMessage":"Expected value which is `Float32Array`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `Float32Array`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1622,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('even integer', value));\n\t}\n}\n\nexport function assertFalsy(value: unknown, message?: string): asserts value is Falsy {\n\tif (!isFalsy(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('falsy', value));\n\t}\n}\n\nexport function assertFiniteNumber(value: unknown, message?: string): asserts value is number {\n\tif (!isFiniteNumber(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('finite number', value));\n\t}\n}\n\nexport function assertFloat32Array(value: unknown, message?: string): asserts value is Float32Array {\n\tif (!isFloat32Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Float32Array', value));\n\t}\n}\n\nexport function assertFloat64Array(value: unknown, message?: string): asserts value is Float64Array {\n\tif (!isFloat64Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('Float64Array', value));\n\t}\n}\n\nexport function assertFormData(value: unknown, message?: string): asserts value is FormData {\n\tif (!isFormData(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('FormData', value));\n\t}\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function assertFunction(value: unknown, message?: string): asserts value is Function {\n\tif (!isFunction(value)) {","sourceCodeStart":1604,"sourceCodeEnd":1640,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1604-L1640","documentation":"Thrown by `assertFloat32Array()` in the @sindresorhus/is type-assertion library when the checked value fails `isFloat32Array()`, which verifies the value's internal tag is `Float32Array` via `Object.prototype.toString`. Assert functions throw a TypeError so TypeScript can narrow the value type after the call; the message interpolates the detected type of the actual value.","triggerScenarios":"Calling `is.assert.float32Array(value)` (or `assertFloat32Array(value)`) with anything other than a real Float32Array — e.g. a plain number array, Float64Array, ArrayBuffer, DataView, or a Node Buffer.","commonSituations":"WebGL/audio/ML code that receives a plain `number[]` from JSON or user input instead of a typed array; passing an ArrayBuffer without wrapping it in `new Float32Array(buffer)`; cross-realm typed arrays are fine (brand check), but structurally similar objects from serialization are not.","solutions":["Convert the input before asserting: `new Float32Array(plainArrayOrBuffer)`.","Check where the value originates (JSON.parse, message ports, WASM boundary) and construct the typed array at that boundary.","If Float64Array is also acceptable, use `is.typedArray(value)` or a union check instead of the strict assertion."],"exampleFix":"// before\nconst data = JSON.parse(payload).samples; // number[]\nassertFloat32Array(data);\n// after\nconst data = new Float32Array(JSON.parse(payload).samples);\nassertFloat32Array(data);","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Float32Array)) {\n  throw new TypeError(`Expected Float32Array, got ${typeof value}`);\n}","typeGuard":"function isFloat32Array(value: unknown): value is Float32Array {\n  return value instanceof Float32Array;\n}","tryCatchPattern":"try {\n  assert.float32Array(value);\n} catch (error) {\n  if (error instanceof TypeError) { /* convert or reject input */ }\n  else throw error;\n}","preventionTips":["Check `value instanceof Float32Array` before calling assert.float32Array","Don't confuse Float32Array with Float64Array or plain number[] — convert explicitly with `Float32Array.from(arr)`","Remember typed arrays from other realms (iframes/workers) may fail instanceof; use `is.float32Array` from the library which handles cross-realm checks"],"tags":["typescript","type-assertion","typed-array","runtime-validation"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}