Report #67904
[bug\_fix] Cannot find name 'Promise' \(or 'Map', 'Set', 'fetch', 'document'\)
This occurs when the TypeScript configuration does not include the library definitions for the runtime APIs being used. The lib compiler option specifies which built-in API groups TypeScript should recognize. If target is set to 'es5' or 'es2015', and lib is not explicitly set to include newer features, Promise and other ES2015\+ globals are not defined. Similarly, 'document', 'window', and other browser APIs require the 'dom' library. The fix is to add the appropriate libraries to the lib array in tsconfig.json, e.g., 'lib': \['es2020', 'dom'\], or raise the target to a version that includes the needed APIs by default \(e.g., 'target': 'es2015' includes Promise, 'es2020' includes BigInt\). For Node.js-specific globals like 'process' or 'Buffer', install '@types/node' and ensure it's included in the compilation.
Journey Context:
Developer starts a new TypeScript project and sets 'target': 'es5' for maximum compatibility, or uses a minimal tsconfig. They write code using 'const p = new Promise\(\(resolve\) => ...\)' and immediately see 'Cannot find name Promise'. They hover over Promise and realize TypeScript doesn't recognize it as a global. They check node\_modules/typescript/lib and see lib.es2015.promise.d.ts exists but isn't loaded. They search online and find references to the 'lib' compiler option. They realize that 'target': 'es5' automatically loads only ES5 lib files \(lib.es5.d.ts\), which excludes Promise, Map, Set, and other ES2015 features. They consider changing target to 'es2015', but need to support older environments. They discover they can keep target as 'es5' for the emitted code syntax, but add 'lib': \['es2015', 'dom'\] to include the type definitions for modern APIs that will be polyfilled or are available in the target runtime. This allows TypeScript to recognize Promise during type-checking while still emitting ES5 syntax.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:27:25.879439+00:00— report_created — created