Experimental support for ES7 async/await
I have fallen in love with 6to5 and traceur's support for async/await. I would love to be able to use this with flow.
I'd love this too. I remember @benjamn built a recast transform for async await. Everyone I know who uses jstransform (ourself included) would love to switch to recast ASAP, so when we do it's nice to know there's a transform waiting.
Typing async/await wasn't too hard to do for Hack, so it shouldn't be too hard to do in Flow too, once there is demand for it!
async/await is supported in regenerator proper right now; I think that es7-async-await package is old.
That's right, I've stopped working on https://github.com/benjamn/es7-async-await in favor of handling async functions in Regenerator, because only Regenerator can take advantage of the optimization of creating a generator object directly, skipping the creation of the GeneratorFunction.
I should also mention that 6to5 uses Regenerator for its async/await support!
+1
It would be particularly awesome if Flow could somehow warn when exceptions might be swallowed by Promises!
Yes async await would be a very nice addition! Any updates on progress? :) :+1:
it shouldn't be too hard to do in Flow too, once there is demand for it!
+1 demand :)
+1 love this too.
+1
I get Unexpected token function on my async keywords.
Is there anyway to workaround this?
:+1:
Async/await support added in v0.12.
I'm still getting errors for the await* syntax.
@johngeorgewright can you give an example?
/* @flow */
function somethingParallel() {}
function somethingElseParallel() {}
async function somethingAsynchronous() {
await* [
somethingParallel(),
somethingElseParallel()
];
}
$ flow
.../test.js:7:8,8: Unexpected token *
Found 1 error
$ flow --version
Flow, a static type checker for JavaScript, version 0.14.0
@johngeorgewright Thanks. The closest thing I could find as far as documentation is this section of the proposal, but I'm not sure if that is being tracked along side async/await in the ES process.
I will note that Babel seems to understand this syntax, so it could very well be an omission here. @sebmck, sorry to drag you into this, but do you know what's up with this feature? Is it a part of the "standard" async/await feature, or is it on a separate schedule/phase?
No worries at all. await* is from an early proposal. You can see a reference here. It's most likely going to be removed in Babel 6.0 as it's not on standards track.
Ah, OK, sorry. So I'm to use await Promise.all()... I hadn't realised that. Thanks.