{"record":{"id":"873e96d1bc13f96b","repo":"OrchardCMS/OrchardCore","slug":"toprimitive-must-return-a-primitive-value-v4-shims","errorCode":null,"errorMessage":"@@toPrimitive must return a primitive value.","messagePattern":"@@toPrimitive must return a primitive value\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/fontawesome-free-6.7.2/js/v4-shims.js","lineNumber":62,"sourceCode":"  }\n  function _objectSpread2(e) {\n    for (var r = 1; r < arguments.length; r++) {\n      var t = null != arguments[r] ? arguments[r] : {};\n      r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {\n        _defineProperty(e, r, t[r]);\n      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {\n        Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));\n      });\n    }\n    return e;\n  }\n  function _toPrimitive(t, r) {\n    if (\"object\" != typeof t || !t) return t;\n    var e = t[Symbol.toPrimitive];\n    if (void 0 !== e) {\n      var i = e.call(t, r || \"default\");\n      if (\"object\" != typeof i) return i;\n      throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n    }\n    return (\"string\" === r ? String : Number)(t);\n  }\n  function _toPropertyKey(t) {\n    var i = _toPrimitive(t, \"string\");\n    return \"symbol\" == typeof i ? i : i + \"\";\n  }\n\n  var S = {\n      classic: {\n        fa: \"solid\",\n        fas: \"solid\",\n        \"fa-solid\": \"solid\",\n        far: \"regular\",\n        \"fa-regular\": \"regular\",\n        fal: \"light\",\n        \"fa-light\": \"light\",\n        fat: \"thin\",","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/fontawesome-free-6.7.2/js/v4-shims.js#L44-L80","documentation":"This TypeError is thrown by the Babel _toPrimitive helper inlined into the compiled FontAwesome v4-shims bundle. The helper converts an object used as a property key via Symbol.toPrimitive; if that method returns an object instead of a primitive, the spec requires throwing this TypeError. It is a runtime error from transpiled ES2015+ code, not from FontAwesome logic itself.","triggerScenarios":"An object whose Symbol.toPrimitive method returns an object (e.g. `{ [Symbol.toPrimitive](hint){ return {} } }`) is used where a primitive is required, such as a property key via _toPropertyKey in compiled code.","commonSituations":"Usually seen when mixing a mis-patched/broken polyfill or corrupted vendor bundle into the page; very rarely hit intentionally by app code that defines a non-compliant Symbol.toPrimitive. In Orchard Core it surfaces only when the v4-shims.js bundle is executed against object keys.","solutions":["Do not return an object from Symbol.toPrimitive; return a string, number, bigint, boolean, or symbol","Remove any custom polyfill overriding Symbol.toPrimitive behavior that violates the spec","Re-restore the pristine v4-shims.js from the fontawesome-free-6.7.2 distribution if the bundle was modified","Verify your build does not re-transpile vendor bundles with a broken helpers plugin"],"exampleFix":"// before\nconst bad = { [Symbol.toPrimitive](hint) { return {}; } };\nconst obj = { [bad]: 1 }; // TypeError: @@toPrimitive must return a primitive value.\n// after\nconst good = { [Symbol.toPrimitive](hint) { return 'key'; } };\nconst obj2 = { [good]: 1 };","handlingStrategy":"validation","validationCode":"function isSafeKey(k) { return typeof k === 'string' || typeof k === 'symbol' || typeof k === 'number'; }","typeGuard":"function hasCompliantToPrimitive(o) { return !(o && typeof o === 'object' && typeof o[Symbol.toPrimitive] === 'function' && (() => { try { const v = o[Symbol.toPrimitive]('default'); return typeof v !== 'object'; } catch { return false; } })()); }","tryCatchPattern":"try { obj[key] = value; } catch (e) { if (e instanceof TypeError && e.message.includes('@@toPrimitive')) { console.error('Bad key:', key); } else { throw e; } }","preventionTips":["Never return objects from Symbol.toPrimitive implementations","Do not apply custom transforms/polyfills to vendor bundles","Keep vendored files byte-identical to upstream distributions"],"tags":["javascript","typeerror","symbol-toprimitive","vendor-bundle"],"backgroundTag":"type-mismatch","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}