{"record":{"id":"c78c4cefce2e9447","repo":"zloirock/core-js","slug":"incompatible-receiver-type-required","errorCode":null,"errorMessage":"Incompatible receiver, ${TYPE} required","messagePattern":"Incompatible receiver, (.+?) required","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core-js/internals/internal-state.js","lineNumber":24,"sourceCode":"var hasOwn = require('../internals/has-own-property');\nvar shared = require('../internals/shared-store');\nvar sharedKey = require('../internals/shared-key');\nvar hiddenKeys = require('../internals/hidden-keys');\n\nvar OBJECT_ALREADY_INITIALIZED = 'Object already initialized';\nvar TypeError = globalThis.TypeError;\nvar WeakMap = globalThis.WeakMap;\nvar set, get, has;\n\nvar enforce = function (it) {\n  return has(it) ? get(it) : set(it, {});\n};\n\nvar getterFor = function (TYPE) {\n  return function (it) {\n    var state;\n    if (!isObject(it) || (state = get(it)).type !== TYPE) {\n      throw new TypeError('Incompatible receiver, ' + TYPE + ' required');\n    } return state;\n  };\n};\n\nif (NATIVE_WEAK_MAP || shared.state) {\n  var store = shared.state || (shared.state = new WeakMap());\n  /* eslint-disable no-self-assign -- prototype methods protection */\n  store.get = store.get;\n  store.has = store.has;\n  store.set = store.set;\n  /* eslint-enable no-self-assign -- prototype methods protection */\n  set = function (it, metadata) {\n    if (store.has(it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);\n    metadata.facade = it;\n    store.set(it, metadata);\n    return metadata;\n  };\n  get = function (it) {","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/zloirock/core-js/blob/84e45fba098dd3a177d5cf2247d06ab8e98d3790/packages/core-js/internals/internal-state.js#L6-L42","documentation":"core-js stores per-instance internal state via internal-state's set/get. getterFor(TYPE) returns an accessor that fetches the state and throws TypeError 'Incompatible receiver, <TYPE> required' when the receiver is not an object or its stored state's type differs from TYPE. It enforces that polyfilled prototype methods are only called on instances of the right class.","triggerScenarios":"Calling a polyfilled method (Map/Set/WeakMap/Promise/DataView internals, etc.) with .call/.apply on a foreign object, calling a prototype method unbound so `this` is undefined, or mixing instances created by two different core-js copies (or core-js vs native) so state types don't match.","commonSituations":"Detached method references: const m = map.get; m(key); duplicate core-js installations from inconsistent dependency versions producing two internal-state registries; applying a polyfilled method to a native instance (or vice versa).","solutions":["Invoke methods on real instances: map.get(key), not extracted function references.","Use .call(instance, ...) with a genuine instance when borrowing methods.","Deduplicate core-js: ensure a single version/install of core-js in node_modules (check with npm ls core-js, dedupe).","Don't mix native and polyfilled instances of the same class in one code path."],"exampleFix":"// before\nvar get = new Map().get;\nget('k'); // TypeError: Incompatible receiver, Map required\n// after\nvar map = new Map();\nmap.get('k');","handlingStrategy":"type-guard","validationCode":"function isMapLike(v){ return v instanceof Map || Object.prototype.toString.call(v) === '[object Map]'; }\nif (!isMapLike(recv)) throw new TypeError('receiver must be a Map instance');","typeGuard":"function isInstanceOfType(v, TYPE){ return !!v && typeof v === 'object' && Object.prototype.toString.call(v) === '[object ' + TYPE + ']'; }","tryCatchPattern":"try { method.apply(recv, args); } catch (e) { if (/Incompatible receiver/.test(e.message)) { bindMethodToCorrectInstance(); } else throw e; }","preventionTips":["Never detach polyfilled prototype methods; keep `this` bound to a real instance.","Ensure exactly one core-js copy in the dependency tree (npm ls core-js / dedupe).","Don't mix native and polyfilled instances of the same class.","Use instance.method(...) directly instead of .call/.apply with ad-hoc receivers."],"tags":["typeerror","internal-state","wrong-this","duplicate-polyfill"],"backgroundTag":"incompatible-receiver-required","analyzedSha":"84e45fba098dd3a177d5cf2247d06ab8e98d3790","analyzedAt":"2026-08-30T20:36:10.323Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}