Property 'allSettled' does not exist on type 'PromiseConstructor'.ts(2339)

The types for Promise.allSettled() were only merged in January, and will apparently be released in TypeScript 3.8.

As an interim solution, you can declare a mock-ish type for the function yourself:

declare interface PromiseConstructor {
    allSettled(promises: Array<Promise<any>>): Promise<Array<{status: 'fulfilled' | 'rejected', value?: any, reason?: any}>>;
}

It's ES2020 and at Stage 4, so not available everywhere without a polyfill. It got typed and merged into TS. Try installing the latest @types/node package and see if that pulls it in.

Update: Looks like it will be adding es2020.promise to the libs, when it does land.

Update: npm i [email protected] woot woot!


To get this running on Linux, I needed the latest typescript version:

npm install -g typescript@latest

Then in your tsconfig you currently need the ES2020.Promise lib. My full tsconfig:

{
  "compilerOptions": {
    "sourceMap": true,
    "module": "commonjs",
    "target": "es5",
    "jsx": "react",
    "esModuleInterop": true,
    "allowJs": true,
    "outDir": "./dist",
    "lib": [
      "ES2020.Promise",
    ]
  },
  "include": [
    "./src"
  ],
  "exclude": [
    "./node_modules",
    "./build"
  ],
  "compileOnSave": true,
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    }
  }
}

Usage: const results = await Promise.allSettled(BatchOfPromises);