TypeScript Version: 3.6.2
Search Terms: promise promise.allSettled allSettled
Node.js 12.x already supports the Promise.allSettled method, as you see by running the following command:
node -e "console.log(typeof Promise.allSettled);"
How can I use this method in TypeScript?
There is a compiler option which enables this method?
This is not a support forum.
Questions should be asked at StackOverflow or on Gitter.im.
I am aware of that. I created this issue because I think that this is kind of a "problem" that should be fixed.
If Promise.allSettled is an ECMAScript feature and its not included in TS's standard library, why this should be considered a "support forum" question?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled
According to mdn,
If it isn't in the lib.d.ts files, you can work around the problem by using declaration merging,
https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Also, omissions or additions the the lib files are covered under CONTRIBUTING.md libdts fixes.
As @AnyhowStep says, they can be added yourself, until they are available in a released version of TypeScript.
I see. Thanks, guys. :)
If it isn't in the
lib.d.tsfiles, you can work around the problem by using declaration merging,https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Sorry, I tried to understand this doc but I couldn't.
And I read lots of similar question - nobody can. How I can extend interface declared in some other file?
For anyone still confused, setting "compilerOptions": {"target": "ES2020"} in your tsconfig.json will allow you to use Promise.allSettled.
Using TypeScript v3.8 or later, if you do not want to change the compilation target you can also add ES2020.Promise to the lib array in the compilerOptions in tsconfig.json:
"lib": [ "ES2020.Promise" ], /* Specify library files to be included in the compilation. */
Most helpful comment
Using TypeScript v3.8 or later, if you do not want to change the compilation target you can also add
ES2020.Promiseto thelibarray in thecompilerOptionsintsconfig.json: