Open NickHeiner opened 3 years ago
This issue no longer reproduces :tada:
With recast@0.21.1
, I get:
Babel result
jest.mock('./my-module', () => wrapped(() => ({
mockedFn: jest.fn()
})));
Recast result
jest.mock('./my-module', () => wrapped(() => ({
mockedFn: jest.fn()
})));
i.e., the Recast result has that necessary pair of parens, just like the Babel result.
The issue does still reproduce if I go back to Recast 0.21.0. So most likely it was fixed by #1068, which was a parenthesization fix that happened between those versions.
I'm using Babel and Recast in conjunction to transform my AST. When I use Babel alone, the output is fine (although not formatted correctly.) When I introduce Recast, it drops parens, changing the program semantics (or introducing a syntax error).
Input code:
Babel plugin:
Transformed results:
Full runnable repro.
We can see that the
()
around the arrow function return expression are dropped. When there are multiple members of the object, this results in a syntax error:Possibly related: #914, #327, #533, #81 Versions:
recast@0.20.5
@babel/core@7.15.5