fix single-arg async arrows when retainLines=true (#8868)
This commit is contained in:
parent
e4929e11f6
commit
de80aefece
@ -111,7 +111,23 @@ export function ArrowFunctionExpression(node: Object) {
|
|||||||
t.isIdentifier(firstParam) &&
|
t.isIdentifier(firstParam) &&
|
||||||
!hasTypes(node, firstParam)
|
!hasTypes(node, firstParam)
|
||||||
) {
|
) {
|
||||||
|
if (
|
||||||
|
this.format.retainLines &&
|
||||||
|
node.loc.start.line < node.body.loc.start.line
|
||||||
|
) {
|
||||||
|
this.token("(");
|
||||||
|
if (firstParam.loc.start.line > node.loc.start.line) {
|
||||||
|
this.indent();
|
||||||
this.print(firstParam, node);
|
this.print(firstParam, node);
|
||||||
|
this.dedent();
|
||||||
|
this._catchUp("start", node.body.loc);
|
||||||
|
} else {
|
||||||
|
this.print(firstParam, node);
|
||||||
|
}
|
||||||
|
this.token(")");
|
||||||
|
} else {
|
||||||
|
this.print(firstParam, node);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this._params(node);
|
this._params(node);
|
||||||
}
|
}
|
||||||
|
|||||||
11
packages/babel-generator/test/fixtures/edgecase/single-arg-async-arrow-with-retainlines/input.js
vendored
Normal file
11
packages/babel-generator/test/fixtures/edgecase/single-arg-async-arrow-with-retainlines/input.js
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
var fn = async (
|
||||||
|
arg
|
||||||
|
) => {}
|
||||||
|
|
||||||
|
async (x)
|
||||||
|
=> {}
|
||||||
|
|
||||||
|
async x => {}
|
||||||
|
|
||||||
|
async (x
|
||||||
|
) => {};
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"retainLines": true
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
var fn = async (
|
||||||
|
arg
|
||||||
|
) => {};
|
||||||
|
|
||||||
|
async (x) =>
|
||||||
|
{};
|
||||||
|
|
||||||
|
async x => {};
|
||||||
|
|
||||||
|
async (x) =>
|
||||||
|
{};
|
||||||
Loading…
x
Reference in New Issue
Block a user