sindresorhus/is · error · TypeError
Expected value which is `BigInt64Array`, received value of t
Error message
Expected value which is `BigInt64Array`, received value of type `${is(value)}`. What it means
Thrown by `assertBigInt64Array(value)` when the value's object tag is not `BigInt64Array`. Only a genuine `BigInt64Array` passes — a `BigUint64Array`, a `Float64Array`/`Int32Array`, a plain array of bigints, an `ArrayBuffer`, or a `DataView` over the same bytes all fail even though they may hold equivalent data.
Source
Thrown at source/index.ts:1492
throw new TypeError(message ?? typeErrorMessage('AsyncGeneratorFunction', value));
}
}
export function assertAsyncIterable<T = unknown>(value: unknown, message?: string): asserts value is AsyncIterable<T> {
if (!isAsyncIterable(value)) {
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));View on GitHub ↗ (pinned to 7821031c66)
Solutions
- Construct the proper view: `new BigInt64Array(arrayOfBigints)` or `new BigInt64Array(buffer, byteOffset, length)` — the byte length must be a multiple of 8.
- If you have a BigUint64Array and the signed type is required, create a signed view over the same buffer: `new BigInt64Array(u.buffer, u.byteOffset, u.length)` (mind reinterpretation of values ≥ 2^63).
- If any 64-bit bigint view is acceptable, assert `assert.any([is.bigInt64Array, is.bigUint64Array], value)`.
- Verify the runtime supports BigInt64Array (Node 10.4+/modern browsers) rather than a fallback shim.
Example fix
// before assert.bigInt64Array([1n, 2n]); // plain Array, throws // after assert.bigInt64Array(new BigInt64Array([1n, 2n]));
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(value instanceof BigInt64Array)) {
// e.g. construct: new BigInt64Array(buffer) — do not pass the raw buffer
} Type guard
const isBigInt64Array = (value) => value instanceof BigInt64Array;
Try / catch
try {
assert.bigInt64Array(value);
} catch (error) {
if (error instanceof TypeError) { /* wrong TypedArray flavor or raw ArrayBuffer */ }
else { throw error; }
} Prevention
- BigUint64Array, Int32Array, and raw ArrayBuffers all fail — the exact TypedArray class matters
- Wrap buffers explicitly with new BigInt64Array(buffer, byteOffset, length) before passing
- Cross-realm instances fail instanceof — prefer the library's is.bigInt64Array guard for values crossing realms/workers
When it happens
Trigger: Passing an ordinary array like `[1n, 2n]` instead of `new BigInt64Array([1n, 2n])`; passing the unsigned variant `BigUint64Array` where the signed one is asserted; passing a raw `ArrayBuffer`/`Buffer` from I/O without wrapping it in the correct view; a `Number`-based typed array used for 64-bit values that actually need bigint precision.
Common situations: WebAssembly/FFI or binary-protocol code where buffers arrive as Node `Buffer`/`ArrayBuffer` and need an explicit `new BigInt64Array(buf.buffer, ...)` view; sign confusion between Int64/Uint64 columns; environments predating BigInt64Array (Safari < 15, old Node) where a polyfill or fallback array is substituted.
Related errors
- Expected value which is `BigUint64Array`, received value of
- Expected value which is `DataView`, received value of type `
- Expected value which is `Int16Array`, received value of type
- Expected value which is `TypedArray`, received value of type
- Expected value which is `Uint8Array`, received value of type
AI-assisted analysis of sindresorhus/is@7821031c66 (2026-07-31).
Data as JSON: /data/errors/154087aeaf585d7f.json.
Report an issue: GitHub ↗.