Handle curly brackets in SwitchCase types

master
James Long 2017-01-09 12:07:39 -05:00
parent 6b582f808c
commit aed3c1af71
3 changed files with 20 additions and 18 deletions

View File

@ -1057,15 +1057,22 @@ else
parts.push("default:");
if (n.consequent.length > 0) {
parts.push(indent(options.tabWidth, concat([
hardline,
path.call(
function(consequentPath) {
return printStatementSequence(consequentPath, options, print);
},
"consequent"
const cons = path.call(
function(consequentPath) {
return printStatementSequence(consequentPath, options, print);
},
"consequent"
);
parts.push(
indent(
options.tabWidth,
concat([
isCurlyBracket(cons) ? " " : hardline,
cons
])
)
])));
);
}
return concat(parts);

View File

@ -113,13 +113,11 @@ function bar2(b) {
if (x == null)
return;
switch (\"\") {
case 0:
{
case 0: {
let y: number = x;
x = \"\";
}
case 1:
{
case 1: {
let z: number = x;
break;
}

View File

@ -251,20 +251,17 @@ export function emitExpression(node: TypedNode): t.Expression {
b.identifier(node.name),
false
);
case \"binary_op\":
{
case \"binary_op\": {
const lhs = emitExpression(node.lhs);
const rhs = emitExpression(node.rhs);
const op = getBinaryOp(node.binaryOp);
return b.binaryExpression(op, lhs, rhs);
}
case \"unary_minus\":
{
case \"unary_minus\": {
const operand = emitExpression(node.op);
return b.unaryExpression(\"-\", operand, true);
}
case \"function_invocation\":
{
case \"function_invocation\": {
const callee = b.memberExpression(
b.identifier(\"fns\"),
b.identifier(node.name),