{"record":{"id":"9a1fe42984b738dc","repo":"zloirock/core-js","slug":"target-is-not-a-typed-array","errorCode":null,"errorMessage":"Target is not a typed array","messagePattern":"Target is not a typed array","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core-js/internals/array-buffer-view-core.js","lineNumber":80,"sourceCode":"};\n\nvar getTypedArrayConstructor = function (it) {\n  var proto = getPrototypeOf(it);\n  if (!isObject(proto)) return;\n  var state = getInternalState(proto);\n  return (state && hasOwn(state, TYPED_ARRAY_CONSTRUCTOR)) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto);\n};\n\nvar isTypedArray = function (it) {\n  if (!isObject(it)) return false;\n  var klass = classof(it);\n  return hasOwn(TypedArrayConstructorsList, klass)\n    || hasOwn(BigIntArrayConstructorsList, klass);\n};\n\nvar aTypedArray = function (it) {\n  if (isTypedArray(it)) return it;\n  throw new TypeError('Target is not a typed array');\n};\n\nvar aTypedArrayConstructor = function (C) {\n  if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C))) return C;\n  throw new TypeError(tryToString(C) + ' is not a typed array constructor');\n};\n\nvar exportTypedArrayMethod = function (KEY, property, forced, options) {\n  if (!DESCRIPTORS) return;\n  if (forced) for (var ARRAY in TypedArrayConstructorsList) {\n    var TypedArrayConstructor = globalThis[ARRAY];\n    if (TypedArrayConstructor && hasOwn(TypedArrayConstructor.prototype, KEY)) try {\n      delete TypedArrayConstructor.prototype[KEY];\n    } catch (error) {\n      // old WebKit bug - some methods are non-configurable\n      try {\n        TypedArrayConstructor.prototype[KEY] = property;\n      } catch (error2) { /* empty */ }","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/zloirock/core-js/blob/84e45fba098dd3a177d5cf2247d06ab8e98d3790/packages/core-js/internals/array-buffer-view-core.js#L62-L98","documentation":"aTypedArray is core-js's internal spec-op guard used by every typed-array method it polyfills. If the receiver's internal class is not in the typed-array constructors list (Int8Array ... Float64Array, BigInt64Array, etc.), it throws 'TypeError: Target is not a typed array'. This mirrors the spec's ValidateTypedArray / RequireInternalSlot([[TypedArrayName]]) requirement.","triggerScenarios":"Calling a typed-array method (e.g. %TypedArray%.prototype.slice/set/subarray/fill) with `this` set to a plain Array, ArrayBuffer, DataView, or non-object via .call/.apply, or calling a polyfilled standalone helper with a non-typed-array argument.","commonSituations":"Manual this-binding tricks (Array.prototype.slice.call(fakeTypedArray) style code adapted backwards); code that duck-types on .length and passes arrays; mocks in tests that aren't real typed arrays; passing a DataView where a typed array is required.","solutions":["Pass a genuine typed array (Int8Array, Uint8Array, Float32Array, BigInt64Array, etc.).","If you have a plain array, convert it first: new Float64Array(arr).","If you have an ArrayBuffer, create a view: new Uint8Array(buffer).","Check the receiver binding: methods must be invoked as arr.method(...), not detached via .call with a wrong this."],"exampleFix":"// before\nUint8Array.prototype.set.call(plainArray, src); // TypeError: Target is not a typed array\n// after\nnew Uint8Array(plainArray).set(src);","handlingStrategy":"type-guard","validationCode":"function isTypedArray(v){ return ArrayBuffer.isView(v) && !(v instanceof DataView); }\nif (!isTypedArray(receiver)) throw new TypeError('receiver must be a typed array');","typeGuard":"function isTypedArray(v){ return v instanceof Int8Array || v instanceof Uint8Array || v instanceof Uint8ClampedArray || v instanceof Int16Array || v instanceof Uint16Array || v instanceof Int32Array || v instanceof Uint32Array || v instanceof Float32Array || v instanceof Float64Array || (typeof BigInt64Array !== 'undefined' && v instanceof BigInt64Array) || (typeof BigUint64Array !== 'undefined' && v instanceof BigUint64Array); }","tryCatchPattern":"try { typedArrayMethod.call(recv, ...args); } catch (e) { if (/Target is not a typed array/.test(e.message)) { recv = new Uint8Array(recv.buffer || recv); retry(); } else throw e; }","preventionTips":["Don't detach typed-array methods from their receiver.","Convert plain arrays with new XArray(arr) before calling typed-array methods.","A DataView is not a typed array — pass a real view type.","Beware mocks in tests: ArrayBuffer.isView alone passes for DataView too."],"tags":["typeerror","typed-array","polyfill","wrong-this"],"backgroundTag":"not-a-typed-array","analyzedSha":"84e45fba098dd3a177d5cf2247d06ab8e98d3790","analyzedAt":"2026-08-30T20:36:10.323Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}