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

  1. Wrap or convert: `Float64Array.from(values)` or `new Float64Array(buffer)`.
  2. Trace the producer of the value — if it intentionally emits Float32Array, either convert or relax the assertion to match.
  3. 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

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


AI-assisted analysis of sindresorhus/is@7821031c66 (2026-07-31). Data as JSON: /data/errors/baf356f070fe5121.json. Report an issue: GitHub ↗.