fixes #71: don't indent block stmts which are children of case clauses
This commit is contained in:
1 parent
e3b41dd6ca
commit
0461b3e6cd
3 files changed
+27
-28
No files matched your search
+3
-4
@@ -1023,10 +1023,9 @@ function genericPrintNoParens(path, options, print) {
|
||||
);
|
||||
|
||||
parts.push(
|
||||
indent(
|
||||
options.tabWidth,
|
||||
concat([ isCurlyBracket(cons) ? " " : hardline, cons ])
|
||||
)
|
||||
isCurlyBracket(cons)
|
||||
? concat([ " ", cons ])
|
||||
: indent(options.tabWidth, concat([ hardline, cons ]))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,15 +105,15 @@ function bar2(b) {
|
||||
return;
|
||||
switch (\"\") {
|
||||
case 0: {
|
||||
let y: number = x;
|
||||
// error: boolean !~> number
|
||||
x = \"\";
|
||||
}
|
||||
let y: number = x;
|
||||
// error: boolean !~> number
|
||||
x = \"\";
|
||||
}
|
||||
case 1: {
|
||||
let z: number = x;
|
||||
// 2 errors: (boolean | string) !~> number
|
||||
break;
|
||||
}
|
||||
let z: number = x;
|
||||
// 2 errors: (boolean | string) !~> number
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
}
|
||||
var w: number = x; // 2 errors: (boolean | string) !~> number
|
||||
|
||||
@@ -264,27 +264,27 @@ export function emitExpression(node: TypedNode): t.Expression {
|
||||
false
|
||||
);
|
||||
case \"binary_op\": {
|
||||
const lhs = emitExpression(node.lhs);
|
||||
const rhs = emitExpression(node.rhs);
|
||||
const lhs = emitExpression(node.lhs);
|
||||
const rhs = emitExpression(node.rhs);
|
||||
|
||||
const op = getBinaryOp(node.binaryOp);
|
||||
return b.binaryExpression(op, lhs, rhs);
|
||||
}
|
||||
const op = getBinaryOp(node.binaryOp);
|
||||
return b.binaryExpression(op, lhs, rhs);
|
||||
}
|
||||
case \"unary_minus\": {
|
||||
const operand = emitExpression(node.op);
|
||||
return b.unaryExpression(\"-\", operand, true);
|
||||
}
|
||||
const operand = emitExpression(node.op);
|
||||
return b.unaryExpression(\"-\", operand, true);
|
||||
}
|
||||
case \"function_invocation\": {
|
||||
const callee = b.memberExpression(
|
||||
b.identifier(\"fns\"),
|
||||
b.identifier(node.name),
|
||||
false
|
||||
);
|
||||
const callee = b.memberExpression(
|
||||
b.identifier(\"fns\"),
|
||||
b.identifier(node.name),
|
||||
false
|
||||
);
|
||||
|
||||
const args = node.parameters.map(n => emitExpression(n));
|
||||
const args = node.parameters.map(n => emitExpression(n));
|
||||
|
||||
return b.callExpression(callee, args);
|
||||
}
|
||||
return b.callExpression(callee, args);
|
||||
}
|
||||
default:
|
||||
throw new Error(\"Unknown expression type: \" + node.type);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user