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
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-06-08 11:47:49 -07:00
1 parent 753ff5f0ac
commit 939734b75e
3 files changed
+13 -1

No files matched your search

+1 -1
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 ? "{|" : "{";
@@ -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
} = {}
`;
+2
View File
@@ -1 +1,3 @@
type A = {disabled?: boolean, error?: string}
const foo: {aasdf?: string; asdf?: number; foob?: string; zzz?: string; yyy: string} = {}