sindresorhus/is · error · TypeError
Expected value which is `Float64Array`, received value of ty
Error message
Expected value which is `Float64Array`, received value of type `${is(value)}`. What it means
Thrown by `assertFloat64Array()` when `isFloat64Array()` returns false. The library uses exact object-tag checks, so only genuine Float64Array instances pass; the TypeError message reports the actual detected type to aid debugging.
Source
Thrown at source/index.ts:1628
throw new TypeError(message ?? typeErrorMessage('falsy', value));
}
}
export function assertFiniteNumber(value: unknown, message?: string): asserts value is number {
if (!isFiniteNumber(value)) {
throw new TypeError(message ?? typeErrorMessage('finite number', value));
}
}
export function assertFloat32Array(value: unknown, message?: string): asserts value is Float32Array {
if (!isFloat32Array(value)) {
throw new TypeError(message ?? typeErrorMessage('Float32Array', value));
}
}
export function assertFloat64Array(value: unknown, message?: string): asserts value is Float64Array {
if (!isFloat64Array(value)) {
throw new TypeError(message ?? typeErrorMessage('Float64Array', value));
}
}
export function assertFormData(value: unknown, message?: string): asserts value is FormData {
if (!isFormData(value)) {
throw new TypeError(message ?? typeErrorMessage('FormData', value));
}
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function assertFunction(value: unknown, message?: string): asserts value is Function {
if (!isFunction(value)) {
throw new TypeError(message ?? typeErrorMessage('Function', value));
}
}
export function assertGenerator(value: unknown, message?: string): asserts value is Generator {
if (!isGenerator(value)) {View on GitHub ↗ (pinned to 7821031c66)
Solutions
- Wrap or convert: `Float64Array.from(values)` or `new Float64Array(buffer)`.
- Trace the producer of the value — if it intentionally emits Float32Array, either convert or relax the assertion to match.
- Use `is(value)` yourself to see what type is actually flowing through before choosing the fix.
Example fix
// before assertFloat64Array(samples); // samples is Float32Array // after const samples64 = Float64Array.from(samples); assertFloat64Array(samples64);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(value instanceof Float64Array)) {
throw new TypeError(`Expected Float64Array, got ${typeof value}`);
} Type guard
function isFloat64Array(value: unknown): value is Float64Array {
return value instanceof Float64Array;
} Try / catch
try {
assert.float64Array(value);
} catch (error) {
if (error instanceof TypeError) { /* handle wrong typed-array kind */ }
else throw error;
} Prevention
- Convert numeric arrays explicitly with `Float64Array.from(arr)` before passing
- Verify the buffer view kind at API boundaries — a DataView or Float32Array over the same buffer is not a Float64Array
- Type function signatures as `Float64Array`, not `ArrayLike<number>`, so the compiler catches mismatches
When it happens
Trigger: `is.assert.float64Array(value)` called with a Float32Array, plain array, ArrayBuffer, Node Buffer, or any non-Float64Array value.
Common situations: Numeric/scientific code mixing 32-bit and 64-bit arrays (e.g. a library returns Float32Array for memory savings while your code asserts Float64Array); deserialized data arriving as plain arrays; WASM heap views of the wrong element type.
Related errors
- Expected value which is `Float32Array`, received value of ty
- Expected value which is `Uint16Array`, received value of typ
- Expected value which is `Uint32Array`, received value of typ
- Expected value which is `BigUint64Array`, received value of
- Expected value which is `empty map`, received value of type
AI-assisted analysis of sindresorhus/is@7821031c66 (2026-07-31).
Data as JSON: /data/errors/baf356f070fe5121.json.
Report an issue: GitHub ↗.