Async functions not friendly to promise extensions

medikoo at
Fri Apr 14 07:59:11 UTC 2017

While Promise methods and functions are friendly for it's extensions (or even
not direct extensions but just thenables), the async function will always
normalize it's result to instance of Promise, even it's ExtendedPromise,
e.g.:class ExtendedPromise extends Promise {};var extendedPromise = new
ExtendedPromise(function (resolve) { resolve();
});extendedPromise.then().constructor === ExtendedPromise // truevar asyncFn
= async function () { return extendedPromise; };asyncFn().constructor ===
ExtendedPromise // falseasyncFn().constructor === Promise // trueThat makes
it cumbersome if we work with promise extensions. What was the reasoning
behind such design?If not thenables in general, the promise extensions I
believe should be passed through (or copied via its constructor.resolve).

View this message in context:
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list