Report #40590
[bug\_fix] TS2339: Property 'allSettled' does not exist on type 'PromiseConstructor' \(or similar for flatMap, at, etc.\)
The \`target\` compilerOption implicitly controls which built-in API types are available via the \`lib\` option. If \`target\` is \`ES2018\`, \`Promise.allSettled\` \(ES2020\) is unknown. Update \`target\` to at least \`ES2020\` \(or \`ES2022\` for \`Array.prototype.at\`\), or explicitly add the required lib files to the \`lib\` array \(e.g., \`"lib": \["ES2020.Promise", "DOM"\]\`\) without changing target.
Journey Context:
Developer is modernizing a codebase and wants to use \`Promise.allSettled\` to handle multiple promises without short-circuiting on rejection. They write \`const results = await Promise.allSettled\(\[fetchUser\(\), fetchOrders\(\)\]\);\`. TypeScript underlines \`allSettled\` with error TS2339: "Property 'allSettled' does not exist on type 'PromiseConstructor'". The developer checks their Node.js version \(18\+\) and knows \`allSettled\` is supported natively. They check their \`tsconfig.json\` and see \`"target": "ES2018"\`, a setting from when the project started years ago. They assume TypeScript automatically knows about newer APIs if the runtime supports them, but realize TypeScript's type definitions are based on the \`target\` and \`lib\` settings, not the local Node version. They try changing \`target\` to \`"ES2020"\`, and the error disappears. They learn that \`target\` implicitly includes library definitions, and to use modern APIs, the tsconfig must declare support for that ECMAScript version or explicitly include the library files.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:36:08.790897+00:00— report_created — created