{"record":{"id":"16c0c4c64b5d4b81","repo":"microsoft/TypeScript","slug":"symbol-iterator-is-not-defined","errorCode":null,"errorMessage":"Symbol.iterator is not defined.","messagePattern":"Symbol\\.iterator is not defined\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/compiler/factory/emitHelpers.ts","lineNumber":1047,"sourceCode":"};\r\n\r\n// ES2015 Destructuring Helpers\r\n\r\nconst valuesHelper: UnscopedEmitHelper = {\r\n    name: \"typescript:values\",\r\n    importName: \"__values\",\r\n    scoped: false,\r\n    text: `\r\n            var __values = (this && this.__values) || function(o) {\r\n                var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n                if (m) return m.call(o);\r\n                if (o && typeof o.length === \"number\") return {\r\n                    next: function () {\r\n                        if (o && i >= o.length) o = void 0;\r\n                        return { value: o && o[i++], done: !o };\r\n                    }\r\n                };\r\n                throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n            };`,\r\n};\r\n\r\n// ES2015 Generator Helpers\r\n\r\n// The __generator helper is used by down-level transformations to emulate the runtime\r\n// semantics of an ES2015 generator function. When called, this helper returns an\r\n// object that implements the Iterator protocol, in that it has `next`, `return`, and\r\n// `throw` methods that step through the generator when invoked.\r\n//\r\n// parameters:\r\n//  @param thisArg  The value to use as the `this` binding for the transformed generator body.\r\n//  @param body     A function that acts as the transformed generator body.\r\n//\r\n// variables:\r\n//  _       Persistent state for the generator that is shared between the helper and the\r\n//          generator body. The state object has the following members:\r\n//            sent() - A method that returns or throws the current completion value.\r","sourceCodeStart":1029,"sourceCodeEnd":1065,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/compiler/factory/emitHelpers.ts#L1029-L1065","documentation":"`__values` throws this variant when `Symbol` itself (or Symbol.iterator) is missing from the runtime entirely — a pre-ES2015 environment without a polyfill. The helper distinguishes it from \"Object is not iterable.\" by checking whether `Symbol.iterator` exists.","triggerScenarios":"Running ES5-targeted TS output on a runtime with no Symbol (old IE, very old Node, embedded JS engines) and no polyfill loaded.","commonSituations":"target: ES5 with no lib/polyfill; shipping to legacy embedded JS engines.","solutions":["Load a Symbol polyfill (e.g. core-js/es6/symbol) before the compiled code runs.","Raise `target` to ES2015+ so the helper isn't emitted.","Run on a runtime that ships Symbol natively."],"exampleFix":"// before\ntsconfig: \"target\": \"es5\", \"lib\": [\"es5\"]  // old runtime -> \"Symbol.iterator is not defined.\"\n\n// after\nrequire(\"core-js/es6/symbol\");   // polyfill first\n// or raise target:\n// tsconfig: \"target\": \"es2015\"","handlingStrategy":"validation","validationCode":"if (typeof Symbol === \"undefined\" || !(Symbol as any).iterator) {\n  throw new Error(\"Symbol.iterator missing; load core-js es6.symbol polyfill or raise target to es2015+.\");\n}","typeGuard":"function hasSymbolIterator(): boolean {\n  return typeof Symbol !== \"undefined\" && !!(Symbol as unknown as { iterator?: symbol }).iterator;\n}","tryCatchPattern":null,"preventionTips":["Load a Symbol polyfill before any iterable code when targeting ES5.","Raise tsconfig target to ES2015+ to drop __values.","Document runtime requirements for ES5 builds."],"tags":["iteration","runtime","polyfill","target","emit-helpers"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}