Use ifBreak instead of shouldBreak (#2063)

shouldBreak is only a heuristic to enforce a break, if it breaks "naturally", then it won't be applied.

Fixes #2055
master
Christopher Chedeau 2017-06-08 11:47:49 -07:00 committed by GitHub
parent 753ff5f0ac
commit 939734b75e
3 changed files with 13 additions and 1 deletions

View File

@ -840,7 +840,7 @@ function genericPrintNoParens(path, options, print, args) {
);
const separator = n.type === "TSInterfaceBody" ||
n.type === "TSTypeLiteral"
? shouldBreak ? semi : ";"
? ifBreak(semi, ";")
: ",";
const fields = [];
const leftBrace = n.exact ? "{|" : "{";

View File

@ -36,7 +36,17 @@ interface InlineMultiple { x: string; y: string }
exports[`type.js 1`] = `
type A = {disabled?: boolean, error?: string}
const foo: {aasdf?: string; asdf?: number; foob?: string; zzz?: string; yyy: string} = {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type A = { disabled?: boolean; error?: string }
const foo: {
aasdf?: string
asdf?: number
foob?: string
zzz?: string
yyy: string
} = {}
`;

View File

@ -1 +1,3 @@
type A = {disabled?: boolean, error?: string}
const foo: {aasdf?: string; asdf?: number; foob?: string; zzz?: string; yyy: string} = {}