Question: you mean just if it's an async arrow, not if it's an async declaration?

Asked By
Asked At
2018-01-25 21:39:57

Found 15 possible answers.

User Answered At Possible Answer
justin-summerlin 2018-01-25 21:40:42 const writeToRecipients = async (item) => { vs async function writeToRecipients(item) {
loganfsmyth 2018-01-25 21:41:02 could certainly be a bug in Babel's transform
ljharb 2018-01-25 21:41:18 interesting
loganfsmyth 2018-01-25 21:43:37 that error sounds like we're converting it to a non-async function, possibly by accident What version of Babel are you using?
justin-summerlin 2018-01-25 21:46:46 6.26, the output when I just do a yarn babel to build *seems* correct, I'm not certain if Jest is building it in an identical manner
loganfsmyth 2018-01-25 21:47:28 I don't remember what else it adds. it's possible they inject something that changes the output somehow
justin-summerlin 2018-01-25 21:50:16 Yeah I can reproduce that pattern and run the built version without a problem but it introduces an error when testing in Jest, I'm going to look into what options it's using It only happens with a single argument, with multiple it keeps the ( on the same line as async which prevents ASI from causing an issue there. I'm getting into a lot of Babel internals and I'm not really sure how to track down why that's happening only in Jest at this point, but I have a workaround. arg =>
The babel output from `babel-jest` is 
const whatever = async ) => {
 if I put that on one line it works fine. Still looking into `jest-runtime` to see what it's doing.
It looks like it only happens when the input source looks like this: 
const whatever = async (
loganfsmyth 2018-01-25 23:55:33 oh boy, that doesn't sound like a Babel issue then, but something in there is definitely assuming there is no line terminator @justin-summerlin Alright nevermind, probably is a Babel bug then when that option is enabled my least favorite option rears its ugly head once again ughhhh hmm actually, 1 sec
kovensky 2018-01-26 00:04:56 jest 22 has source map support now, maybe we can finally delete that silly option :<
loganfsmyth 2018-01-26 00:07:47 @justin-summerlin Filed though I honestly don't know if we'll fix it
justin-summerlin 2018-01-26 01:03:41 Cool, thanks for looking into that.
gregborrelly 2018-01-26 17:52:41 Hey guys, I'm looking to contribute. I went over the list of issues, and was not able to find one that was not taken and friendly to beginners. Would you mind recommending a good first issue ?
tolmasky 2018-01-27 06:45:32 can babel-register apply different transforms to different paths? but that does not appear to work and hoping the babel-registers would "stack" i tried doing babel-register twice, and using ignore: on both to not collide
nicolo-ribaudo 2018-01-27 09:13:05 In Babel 7 there is an overrides option, which allows you to customize the plugins based on the file path.
loganfsmyth 2018-01-27 19:30:40 @tolmasky Nope they don't stack. @nicolo-ribaudo ’s suggestion would be the right one in 7.x. I've also thought of exposing an API for instantiating independent instances, but it doesn't currently exist

Related Questions