{"record":{"id":"f73557202a2d0556","repo":"zloirock/core-js","slug":"symbol-is-not-a-constructor","errorCode":null,"errorMessage":"Symbol is not a constructor","messagePattern":"Symbol is not a constructor","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core-js/modules/es.symbol.constructor.js","lineNumber":168,"sourceCode":"};\n\nvar $getOwnPropertySymbols = function (O) {\n  var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;\n  var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));\n  var result = [];\n  $forEach(names, function (key) {\n    if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {\n      push(result, AllSymbols[key]);\n    }\n  });\n  return result;\n};\n\n// `Symbol` constructor\n// https://tc39.es/ecma262/#sec-symbol-constructor\nif (!NATIVE_SYMBOL) {\n  $Symbol = function Symbol() {\n    if (isPrototypeOf(SymbolPrototype, this)) throw new TypeError('Symbol is not a constructor');\n    var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);\n    var tag = uid(description);\n    var setter = function (value) {\n      var $this = this === undefined ? globalThis : this;\n      if ($this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);\n      if (hasOwn($this, HIDDEN) && hasOwn($this[HIDDEN], tag)) $this[HIDDEN][tag] = false;\n      var descriptor = createPropertyDescriptor(1, value);\n      try {\n        setSymbolDescriptor($this, tag, descriptor);\n      } catch (error) {\n        if (!(error instanceof RangeError)) throw error;\n        fallbackDefineProperty($this, tag, descriptor);\n      }\n    };\n    if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });\n    return wrap(tag, description);\n  };\n","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/zloirock/core-js/blob/84e45fba098dd3a177d5cf2247d06ab8e98d3790/packages/core-js/modules/es.symbol.constructor.js#L150-L186","documentation":"core-js's Symbol polyfill implements Symbol as a plain function (not a native class) to work without new.target checks, so it manually throws a TypeError when called with new (detected via isPrototypeOf(SymbolPrototype, this)). Per spec, Symbol is not a constructor and must be called as Symbol(description).","triggerScenarios":"new Symbol('x') — calling Symbol with the new operator; a transpiler/minifier or factory wrapper that emits new Sym(...) for a variable bound to Symbol; frameworks that genericly instantiate classes via new for a value that is actually the Symbol function.","commonSituations":"TypeScript/Babel downleveling a class-typed variable holding Symbol and calling new on it; IDE auto-complete adding 'new' before Symbol; migrating code from a wrapper library exposing newable Symbol-like class to core-js polyfilled Symbol on older engines (IE11 etc.); reflection utilities that blindly apply new to imported functions.","solutions":["Remove the new operator: call Symbol('description') directly.","If you need a Symbol-like class instance, create your own wrapper object instead of new Symbol().","Check generated/transpiled code for 'new Symbol' and fix the source or tsconfig (avoid typing the value as a constructable).","On engines without native Symbol, keep the polyfill call form — core-js follows spec, so this throw is correct behavior."],"exampleFix":"// before\nconst sym = new Symbol('id'); // TypeError\n// after\nconst sym = Symbol('id');","handlingStrategy":"type-guard","validationCode":"function safeSymbol(desc) {\n  if (typeof Symbol !== 'function') throw new TypeError('Symbol unsupported');\n  return Symbol(desc);\n}","typeGuard":"function isSymbolValue(v) { return typeof v === 'symbol'; }\n// ensure call form: typeof Symbol === 'function' && !usingNew — call Symbol(x) directly","tryCatchPattern":"try {\n  const sym = new Symbol('id'); // replace with direct call\n} catch (e) {\n  if (e instanceof TypeError && /Symbol is not a constructor/.test(e.message)) {\n    const sym = Symbol('id');\n  } else throw e;\n}","preventionTips":["Never call Symbol with new — it is not a constructor per spec.","Search codebase/generated bundles for 'new Symbol'.","Check transpiler/minifier output when wrapping Symbol dynamically.","Use TypeScript: type the value as symbol (not Symbol constructor) to prevent new calls."],"tags":["javascript","polyfill","symbol","typeerror"],"backgroundTag":"symbol-is-not-a-constructor","analyzedSha":"84e45fba098dd3a177d5cf2247d06ab8e98d3790","analyzedAt":"2026-08-30T20:36:10.323Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}