Fix forced trailing comma (#382)

We shouldn't output trailing commas when there is a forced one when we break.

Fixes #380
master
Christopher Chedeau 2017-01-22 12:34:35 -08:00 committed by GitHub
parent 1f92218a06
commit 3d95e8317b
3 changed files with 10 additions and 1 deletions

View File

@ -637,7 +637,7 @@ function genericPrintNoParens(path, options, print) {
])
),
needsForcedTrailingComma ? "," : "",
ifBreak(options.trailingComma ? "," : ""),
ifBreak(!needsForcedTrailingComma && options.trailingComma ? "," : ""),
options.bracketSpacing ? line : softline,
"]"
])

View File

@ -12,6 +12,8 @@ function f(
) {}
declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; }
[superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,,]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare class C {
f(
@ -31,5 +33,10 @@ declare class C {
...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong
): void,
}
[
superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,
,
];
"
`;

View File

@ -11,3 +11,5 @@ function f(
) {}
declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; }
[superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,,]