Async functions not friendly to promise extensions

Matthias welp boekewurm at
Fri Apr 14 10:53:11 UTC 2017

> I hope this explains it a bit for you.

Sorry, but it didn't explain much. What to you mean by "that'd break when
using multiple returns with different types" ? Can you throw some simple


var k = new Promise((acc, rej) => window.setTimeout(1000, ()=>


var k = (async function() {await window.setTimeout(1000); return

type of var k cannot be determined when the promise is made, due to the
timeout not yet having returned. Ahead-of-time determining of type is
really impossible with unpure functions, which must be available in async
functions (e.g. for fetch). You can wrap your async function call in a
custom promise (which would have your desired result), changing promise
instance class hierarchies on-the-fly would make promises much less
deterministic than what they are now, and would​ introduce confusion:
typeof k would change depending on how long your program has run.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list