{"record":{"id":"adff23f72262e358","repo":"dianping/cat","slug":"typeof-prototype-typeof-prototype-object","errorCode":null,"errorMessage":"typeof prototype[{typeof prototype}] != 'object'","messagePattern":"typeof prototype\\[(.+?)\\] != 'object'","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/editor/worker-xquery.js","lineNumber":49293,"sourceCode":"            empty.constructor =\n            empty.hasOwnProperty =\n            empty.propertyIsEnumerable =\n            empty.isPrototypeOf =\n            empty.toLocaleString =\n            empty.toString =\n            empty.valueOf =\n            empty.__proto__ = null;\n            return empty;\n        }\n    }\n\n    Object.create = function create(prototype, properties) {\n        var object;\n        if (prototype === null) {\n            object = createEmpty();\n        } else {\n            if (typeof prototype != \"object\")\n                throw new TypeError(\"typeof prototype[\"+(typeof prototype)+\"] != 'object'\");\n            var Type = function () {};\n            Type.prototype = prototype;\n            object = new Type();\n            object.__proto__ = prototype;\n        }\n        if (properties !== void 0)\n            Object.defineProperties(object, properties);\n        return object;\n    };\n}\n\nfunction doesDefinePropertyWork(object) {\n    try {\n        Object.defineProperty(object, \"sentinel\", {});\n        return \"sentinel\" in object;\n    } catch (exception) {\n    }\n}","sourceCodeStart":49275,"sourceCodeEnd":49311,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/editor/worker-xquery.js#L49275-L49311","documentation":"This is the es5-shim polyfill for Object.create bundled into worker-xquery.js. ES5 spec requires the first argument (the prototype) to be an object or null; the shim explicitly throws a TypeError with a diagnostic that embeds the actual typeof when a primitive is passed. Native engines throw a vaguer error, so this message is a shim-specific improvement.","triggerScenarios":"Calling Object.create with a non-object, non-null first argument: Object.create('foo'), Object.create(42), Object.create(undefined), Object.create(false). Often happens when a variable expected to hold a prototype object is actually a string/number (e.g. reading a config value or a JSON-parsed value that came back as a scalar).","commonSituations":"Passing a class name or constructor name string instead of the constructor's .prototype; passing undefined because a lookup returned nothing; old browsers (IE8) where the shim is active and library code assumed an object was present.","solutions":["Check the value passed as prototype: it must be an object, a function (use MyCtor.prototype), or explicitly null.","If you want an empty dictionary-style object, use Object.create(null), not Object.create(undefined) or Object.create({}) with a missing variable.","Trace the argument upstream — this message tells you the runtime type, so log the variable before the call to find where it became a primitive.","If the call is inside a third-party library, update it: newer builds may already guard against primitives."],"exampleFix":"// before\nvar proto = config.baseProto; // may be undefined/string\nvar obj = Object.create(proto);\n\n// after\nvar proto = config.baseProto;\nif (proto !== null && (typeof proto !== 'object' && typeof proto !== 'function')) {\n  throw new TypeError('config.baseProto must be an object or null, got ' + typeof proto);\n}\nvar obj = Object.create(proto);","handlingStrategy":"type-guard","validationCode":"function isValidPrototype(p) {\n  return p === null || (typeof p === 'object') || (typeof p === 'function');\n}\nif (!isValidPrototype(proto)) throw new Error('bad prototype: ' + typeof proto);\nvar obj = Object.create(proto);","typeGuard":"function isPrototypeOrNull(p) {\n  return p === null || typeof p === 'object' || typeof p === 'function';\n}","tryCatchPattern":null,"preventionTips":["Always pass MyCtor.prototype, not the constructor or its name string","Use Object.create(null) explicitly for prototype-less objects","Log typeof of dynamic prototypes during development"],"tags":["es5-shim","polyfill","object-create","typeerror","legacy-browser"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}