I am learning Promise.any from the following site. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any The IDE does not show any error, but while running using yarn command , I am getting the following error.
E:\typescript-2020-1\promise-usages-1\lib\basics1\promise-any.service.js:18
Promise.any([
^
TypeError: Promise.any is not a function
at PromiseAnyService.validateAll_Type1 (E:\typescript-2020-1\promise-usages-1\lib\basics1\promise-any.service.js:18:17)
at Object.<anonymous> (E:\typescript-2020-1\promise-usages-1\lib\test.js:35:7)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
ERROR Command failed with exit code 1.
I have written the simple code to test. Please help where I am doing wrong in a Typescript class.
const promise1 = Promise.reject(0);
const promise2 = new Promise((resolve) => setTimeout(resolve, 100, 'quick'));
const promise3 = new Promise((resolve) => setTimeout(resolve, 500, 'slow'));
const proms = [promise1, promise2, promise3];
Promise.any(proms).then((result) => console.log(result));
Currently I am using NodeJs 12 and Typescript 3.8.3