It's a bit of a moot point now that async/await is supported by all major, modern JavaScript engines, but I've always wondered why Babel converts async functions to generator functions rather than to Promises, since async/await is just syntactic sugar for promises in the first place.

It looks like generators came in in ES5, promises were introduced in ES6, and async/await was in the ES7 standard, so I'm guessing that after the regenerator runtime was written in ES5, the Babel folks just didn't see a point in rewriting it to use promises. But, if there's another reason, I'm curious.

  • 3
    Because it's trying to emit backwards compatible code and, as you point out, generators were available earlier than promises. – jonrsharpe Apr 28 '19 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.