sindresorhus/is · error · TypeError

Expected value which is `BigUint64Array`, received value of

Error message

Expected value which is `BigUint64Array`, received value of type `${is(value)}`.

What it means

Thrown by `assertBigUint64Array()` in the @sindresorhus/is library when the checked value fails the `isBigUint64Array` predicate (getObjectType === 'BigUint64Array'). The assertion exists so downstream code can safely treat the value as a BigUint64Array; the message interpolates the value's detected type via `is(value)` to aid debugging.

Source

Thrown at source/index.ts:1498

		throw new TypeError(message ?? typeErrorMessage('AsyncIterable', value));
	}
}

export function assertBigint(value: unknown, message?: string): asserts value is bigint {
	if (!isBigint(value)) {
		throw new TypeError(message ?? typeErrorMessage('bigint', value));
	}
}

export function assertBigInt64Array(value: unknown, message?: string): asserts value is BigInt64Array {
	if (!isBigInt64Array(value)) {
		throw new TypeError(message ?? typeErrorMessage('BigInt64Array', value));
	}
}

export function assertBigUint64Array(value: unknown, message?: string): asserts value is BigUint64Array {
	if (!isBigUint64Array(value)) {
		throw new TypeError(message ?? typeErrorMessage('BigUint64Array', value));
	}
}

export function assertBlob(value: unknown, message?: string): asserts value is Blob {
	if (!isBlob(value)) {
		throw new TypeError(message ?? typeErrorMessage('Blob', value));
	}
}

export function assertBoolean(value: unknown, message?: string): asserts value is boolean {
	if (!isBoolean(value)) {
		throw new TypeError(message ?? typeErrorMessage('boolean', value));
	}
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function assertBoundFunction(value: unknown, message?: string): asserts value is Function {
	if (!isBoundFunction(value)) {

View on GitHub ↗ (pinned to 7821031c66)

Solutions

  1. Verify the producer actually creates a `BigUint64Array` — check whether you meant `assert.bigInt64Array` for signed data.
  2. Wrap raw buffers before asserting: `new BigUint64Array(arrayBuffer)`.
  3. If the value crossed a serialization boundary (JSON, postMessage without transfer), reconstruct the typed array from the raw numbers/bigints.
  4. Log `is(value)` output to see the actual detected type and fix the call site.

Example fix

// before
assert.bigUint64Array(dataFromJson);
// after
assert.bigUint64Array(new BigUint64Array(dataFromJson.map(BigInt)));
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(value instanceof BigUint64Array)) {
  // convert or reject before calling the API
}

Type guard

function isBigUint64Array(value: unknown): value is BigUint64Array {
  return value instanceof BigUint64Array;
}

Try / catch

try {
  assert.bigUint64Array(value);
} catch (error) {
  if (error instanceof TypeError) {
    // received a different typed array or plain array — convert explicitly
  } else throw error;
}

Prevention

When it happens

Trigger: Calling `assert.bigUint64Array(value)` / `assertBigUint64Array(value)` with anything that is not a real BigUint64Array: a BigInt64Array, a plain Array of bigints, an ArrayBuffer, a Uint8Array, or a typed array from another realm serialized to JSON.

Common situations: Confusing the signed BigInt64Array with the unsigned BigUint64Array; passing raw ArrayBuffers from WebSocket/fetch binary payloads without wrapping; deserializing structured data (JSON turns typed arrays into plain objects/arrays); Node Buffer passed where a 64-bit view was expected.

Related errors


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