Closed AndrewSouthpaw closed 5 years ago
Well, it's at least nothing wrong with my setup. I tried doing it in the fast-async
test file, and it had the same error.
Is there a reason we can't await non Promises? At least according to MDN you should be able to await any value.
With babel 7 your snippet works fine 🤔
Interesting. Worth noting that for me and the test scaffold it's using Babel 6.
This is documented in https://github.com/MatAtBread/nodent#differences-from-the-es7-specification
Nodent (used by fast-async) by default doesn't allow waiting on a non-promise as it's a significant performance hit. You can change the default to permit this using the fast-async spec
or wrapAwait
compiler options (see https://github.com/MatAtBread/fast-async#usage).
fast-async@7 sets this by default (you can unset it if you wish), by popular demand.
Ah, that explains it, I was unfamiliar with nodent. Thanks for explaining!
Using Babel 6, it appears right now that I cannot
await
any non-Promise value. E.g.throws
Uncaught (in promise) TypeError: 1.then is not a function
. Is this by design, or is there something wrong with my setup?