parent
f56f9e5e8f
commit
2ef169eb67
|
@ -816,9 +816,16 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
case "TSInterfaceBody":
|
||||
case "TSTypeLiteral": {
|
||||
const isTypeAnnotation = n.type === "ObjectTypeAnnotation";
|
||||
const shouldBreak =
|
||||
n.type !== "ObjectPattern" &&
|
||||
util.hasNewlineInRange(
|
||||
options.originalText,
|
||||
util.locStart(n),
|
||||
util.locEnd(n)
|
||||
);
|
||||
const separator = n.type === "TSInterfaceBody" ||
|
||||
n.type === "TSTypeLiteral"
|
||||
? semi
|
||||
? shouldBreak ? semi : ";"
|
||||
: ",";
|
||||
const fields = [];
|
||||
const leftBrace = n.exact ? "{|" : "{";
|
||||
|
@ -921,14 +928,6 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
return content;
|
||||
}
|
||||
|
||||
const shouldBreak =
|
||||
n.type !== "ObjectPattern" &&
|
||||
util.hasNewlineInRange(
|
||||
options.originalText,
|
||||
util.locStart(n),
|
||||
util.locEnd(n)
|
||||
);
|
||||
|
||||
return group(content, { shouldBreak });
|
||||
}
|
||||
case "PropertyPattern":
|
||||
|
|
|
@ -7,6 +7,8 @@ interface MultiLine {
|
|||
x: string;
|
||||
y: string;
|
||||
}
|
||||
|
||||
interface InlineMultiple { x: string; y: string }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
interface Inline { x: string }
|
||||
|
||||
|
@ -15,4 +17,13 @@ interface MultiLine {
|
|||
y: string
|
||||
}
|
||||
|
||||
interface InlineMultiple { x: string; y: string }
|
||||
|
||||
`;
|
||||
|
||||
exports[`type.js 1`] = `
|
||||
type A = {disabled?: boolean, error?: string}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
type A = { disabled?: boolean; error?: string }
|
||||
|
||||
`;
|
||||
|
|
|
@ -4,3 +4,5 @@ interface MultiLine {
|
|||
x: string;
|
||||
y: string;
|
||||
}
|
||||
|
||||
interface InlineMultiple { x: string; y: string }
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
type A = {disabled?: boolean, error?: string}
|
Loading…
Reference in New Issue