Fix missing trailing commas on flow generics (#1381)

master
Brian Ng 2017-04-21 15:57:21 -05:00 committed by Christopher Chedeau
parent 96e5c889e3
commit c0a0bf46bc
4 changed files with 74 additions and 0 deletions

View File

@ -1864,6 +1864,7 @@ function genericPrintNoParens(path, options, print, args) {
join(concat([",", line]), path.map(print, "params"))
])
),
ifBreak(shouldPrintComma(options, "all") ? "," : ""),
softline,
">"
])

View File

@ -26,3 +26,68 @@ var X = {
};
`;
exports[`break.js 2`] = `
var X = {
perform: function<
A, B, C, D, E, F, G,
T: (a: A, b: B, c: C, d: D, e: E, f: F) => G // eslint-disable-line space-before-function-paren
>(
method: T, scope: any,
a: A, b: B, c: C, d: D, e: E, f: F,
): G {
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var X = {
perform: function<
A,
B,
C,
D,
E,
F,
G,
T: (a: A, b: B, c: C, d: D, e: E, f: F) => G, // eslint-disable-line space-before-function-paren
>(method: T, scope: any, a: A, b: B, c: C, d: D, e: E, f: F): G {},
};
`;
exports[`trailing.js 1`] = `
type State = {
errors: Immutable.Map<
Ahohohhohohohohohohohohohohooh,
Fbt | Immutable.Map<ErrorIndex, Fbt>
>,
shouldValidate: boolean,
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type State = {
errors: Immutable.Map<
Ahohohhohohohohohohohohohohooh,
Fbt | Immutable.Map<ErrorIndex, Fbt>
>,
shouldValidate: boolean
};
`;
exports[`trailing.js 2`] = `
type State = {
errors: Immutable.Map<
Ahohohhohohohohohohohohohohooh,
Fbt | Immutable.Map<ErrorIndex, Fbt>
>,
shouldValidate: boolean,
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type State = {
errors: Immutable.Map<
Ahohohhohohohohohohohohohohooh,
Fbt | Immutable.Map<ErrorIndex, Fbt>,
>,
shouldValidate: boolean,
};
`;

View File

@ -1 +1,2 @@
run_spec(__dirname);
run_spec(__dirname, { trailingComma: 'all' });

View File

@ -0,0 +1,7 @@
type State = {
errors: Immutable.Map<
Ahohohhohohohohohohohohohohooh,
Fbt | Immutable.Map<ErrorIndex, Fbt>
>,
shouldValidate: boolean,
};