{"record":{"id":"fd2d0dccd9fde795","repo":"microsoft/TypeScript","slug":"symbol-asynciterator-is-not-defined","errorCode":null,"errorMessage":"Symbol.asyncIterator is not defined.","messagePattern":"Symbol\\.asyncIterator is not defined\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/compiler/factory/emitHelpers.ts","lineNumber":853,"sourceCode":"            };`,\r\n};\r\n\r\nconst awaitHelper: UnscopedEmitHelper = {\r\n    name: \"typescript:await\",\r\n    importName: \"__await\",\r\n    scoped: false,\r\n    text: `\r\n            var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }`,\r\n};\r\n\r\nconst asyncGeneratorHelper: UnscopedEmitHelper = {\r\n    name: \"typescript:asyncGenerator\",\r\n    importName: \"__asyncGenerator\",\r\n    scoped: false,\r\n    dependencies: [awaitHelper],\r\n    text: `\r\n        var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\r\n            if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n            var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n            return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n            function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n            function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n            function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n            function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n            function fulfill(value) { resume(\"next\", value); }\r\n            function reject(value) { resume(\"throw\", value); }\r\n            function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n        };`,\r\n};\r\n\r\nconst asyncDelegator: UnscopedEmitHelper = {\r\n    name: \"typescript:asyncDelegator\",\r\n    importName: \"__asyncDelegator\",\r\n    scoped: false,\r\n    dependencies: [awaitHelper],\r\n    text: `\r","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/compiler/factory/emitHelpers.ts#L835-L871","documentation":"`__asyncGenerator` downlevels async generator functions for pre-ES2018 targets. It checks `Symbol.asyncIterator` and throws if it's missing, because the async-iteration protocol cannot operate without that well-known symbol.","triggerScenarios":"Running the emitted code on a runtime without Symbol.asyncIterator (Node < 10, old browsers) and with no polyfill loaded.","commonSituations":"tsconfig `target` set to ES2015/ES2017 while running on an older runtime; shipping compiled output to legacy browsers without polyfills.","solutions":["Raise `target` to ES2018 or higher so TypeScript no longer emits this helper.","Load a polyfill that defines Symbol.asyncIterator (e.g. core-js) before the compiled code runs.","Bump the runtime (Node >= 10) to one with native Symbol.asyncIterator."],"exampleFix":"// before\ntsconfig: \"target\": \"es2015\"  // emits __asyncGenerator, throws on old runtimes\n\n// after\ntsconfig: \"target\": \"es2018\"  // native async iterators, no helper\n// or, at runtime before app code:\nrequire(\"core-js/features/symbol/async-iterator\");","handlingStrategy":"validation","validationCode":"// Detect the missing symbol before relying on async generators.\nif (typeof Symbol === \"undefined\" || !(Symbol as any).asyncIterator) {\n  throw new Error(\"Symbol.asyncIterator missing; load a polyfill or raise tsconfig target to es2018+.\");\n}","typeGuard":"function hasAsyncIterator(): boolean {\n  return typeof Symbol !== \"undefined\" && !!(Symbol as unknown as { asyncIterator?: symbol }).asyncIterator;\n}","tryCatchPattern":null,"preventionTips":["Set tsconfig target to ES2018+ when the runtime supports it.","Load core-js Symbol.asyncIterator polyfill in apps targeting older runtimes.","Document the minimum Node/browser version in package.json engines."],"tags":["async","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"}