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

I’m trying to use the Promise.allSettled API with TypeScript. Code here:

server.test.ts:

it('should partial success if QPS > 50', async () => {
  const requests: any[] = [];
  for (let i = 0; i < 51; i++) {
    requests.push(rp('http://localhost:3000/place'));
  }
  await Promise.allSettled(requests);
  // ...
});

But TSC throws an error:

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

I already added these values to the lib option in tsconfig.json:

tsconfig.json:

{
  "compilerOptions": {
    /* Basic Options */
    "target": "ES2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
    "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
    "lib": [
      "ES2015",
      "ES2016",
      "ES2017",
      "ES2018",
      "ES2019",
      "ES2020",
      "ESNext"
    ] 
   // ...
}

TypeScript version: "typescript": "^3.7.3"

So, how can I solve this? I know I can use an alternative module, but I am curious about working with TypeScript natively.

112 thoughts on “Property 'allSettled' does not exist on type 'PromiseConstructor'.ts(2339)”

  1. Pingback: keto protein bars
  2. Excellent website you have here but I was wondering
    if you knew of any message boards that cover the same
    topics discussed in this article? I’d really love to be a part
    of online community where I can get opinions from other experienced individuals that share
    the same interest. If you have any suggestions, please let me know.
    Many thanks!

    Reply
  3. Hey there! I realize this is sort of off-topic but I had to ask.
    Does operating a well-established website such as yours require a
    large amount of work? I am completely new to blogging however I
    do write in my diary daily. I’d like to start a blog so I can easily share my own experience and thoughts online.

    Please let me know if you have any recommendations or tips for brand new aspiring
    blog owners. Thankyou!

    Reply
  4. Pingback: gay amputee dating
  5. I’m really enjoying the design and layout of your blog.
    It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a developer to create your theme?
    Fantastic work!

    Reply
  6. You’re so cool! I don’t suppose I’ve truly read a single thing like that before.
    So wonderful to find someone with genuine thoughts on this topic.
    Seriously.. thanks for starting this up. This web site is one thing that is needed on the web, someone with
    some originality!

    Reply
  7. After I originally commented I seem to have clicked the
    -Notify me when new comments are added- checkbox and now each time a
    comment is added I receive 4 emails with the same comment.
    Perhaps there is a way you are able to remove me from that service?
    Cheers!

    Reply
  8. Hey! Quick question that’s entirely off topic. Do you know
    how to make your site mobile friendly? My website looks weird when viewing from my iphone 4.
    I’m trying to find a template or plugin that might be able to resolve this problem.
    If you have any recommendations, please share.
    Thank you!

    Reply
  9. Hey there would you mind letting me know which webhost you’re
    using? I’ve loaded your blog in 3 completely different browsers and I must say
    this blog loads a lot faster then most. Can you recommend a
    good web hosting provider at a reasonable price?

    Thanks a lot, I appreciate it!

    Reply
  10. Wonderful items from you, man. I have take into account your stuff
    previous to and you’re simply too magnificent.
    I really like what you’ve received right here, certainly
    like what you’re saying and the way wherein you say it.
    You’re making it entertaining and you still care for to stay it wise.

    I can not wait to read far more from you. This is actually a wonderful site.

    Reply
  11. Greate post. Keep writing such kind of information on your site.
    Im really impressed by it.
    Hello there, You’ve performed an excellent job. I will certainly digg it and in my view suggest to
    my friends. I’m sure they will be benefited from this web site.

    Reply
  12. Hi, i feel that i saw you visited my site so i got here to go back the prefer?.I’m trying to in finding things to enhance my site!I guess its ok to make use of some of your ideas!!

    Reply
  13. Hello there, I found your web site by way of Google while looking for a related matter, your site came up, it looks good.
    I’ve bookmarked it in my google bookmarks.
    Hello there, simply became aware of your blog thru Google, and found
    that it’s truly informative. I’m gonna watch out for brussels.

    I’ll appreciate in case you continue this
    in future. Numerous people will probably be benefited from your writing.
    Cheers!

    Reply

Leave a Comment