const {resolve} = Promise; // fails

Andrea Giammarchi andrea.giammarchi at
Thu Jul 19 11:56:34 UTC 2018

As quickly discussed on Twitter, it's very inconvenient and inconsistent
that the following fails:

const {resolve, reject} = Promise;

resolve(123); // throws

Compared to every other public static method in ECMAScript that works,
including those methods that might need the contextual class, as it is for
the Array.from case.

const {from} = Array;

from({0: 'abc', length: 1}); // ["abc"] // all good

Why cannot Promise methods fallback to Promise constructor when the
class/context is not available?

Wouldn't be simple/reasonable change to make so that developers
expectations would be preserved?

Best Regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list