Inline nullable in flow generics (#1426)
This commit is contained in:
1 parent
fff743024c
commit
9c826c2ed5
4 files changed
+60
-3
No files matched your search
+3
-1
@@ -1852,7 +1852,9 @@ function genericPrintNoParens(path, options, print, args) {
|
||||
case "TypeParameterDeclaration":
|
||||
case "TypeParameterInstantiation": {
|
||||
const shouldInline =
|
||||
n.params.length === 1 && n.params[0].type === "ObjectTypeAnnotation";
|
||||
n.params.length === 1 &&
|
||||
(n.params[0].type === "ObjectTypeAnnotation" ||
|
||||
n.params[0].type === "NullableTypeAnnotation");
|
||||
|
||||
if (shouldInline) {
|
||||
return concat(["<", join(", ", path.map(print, "params")), ">"]);
|
||||
|
||||
@@ -54,6 +54,52 @@ var X = {
|
||||
|
||||
`;
|
||||
|
||||
exports[`nullable.js 1`] = `
|
||||
function formatEntireFile(
|
||||
fileVersion: FileVersion,
|
||||
range: atom$Range,
|
||||
): Promise<?{
|
||||
newCursor?: number,
|
||||
formatted: string,
|
||||
}> {}
|
||||
|
||||
function foo(): Promise<?boolean> {}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function formatEntireFile(
|
||||
fileVersion: FileVersion,
|
||||
range: atom$Range
|
||||
): Promise<?{
|
||||
newCursor?: number,
|
||||
formatted: string
|
||||
}> {}
|
||||
|
||||
function foo(): Promise<?boolean> {}
|
||||
|
||||
`;
|
||||
|
||||
exports[`nullable.js 2`] = `
|
||||
function formatEntireFile(
|
||||
fileVersion: FileVersion,
|
||||
range: atom$Range,
|
||||
): Promise<?{
|
||||
newCursor?: number,
|
||||
formatted: string,
|
||||
}> {}
|
||||
|
||||
function foo(): Promise<?boolean> {}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function formatEntireFile(
|
||||
fileVersion: FileVersion,
|
||||
range: atom$Range,
|
||||
): Promise<?{
|
||||
newCursor?: number,
|
||||
formatted: string,
|
||||
}> {}
|
||||
|
||||
function foo(): Promise<?boolean> {}
|
||||
|
||||
`;
|
||||
|
||||
exports[`trailing.js 1`] = `
|
||||
type State = {
|
||||
errors: Immutable.Map<
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
run_spec(__dirname);
|
||||
run_spec(__dirname, { trailingComma: 'all' });
|
||||
run_spec(__dirname, null, ["babylon"]);
|
||||
run_spec(__dirname, { trailingComma: 'all' }, ["babylon"]);
|
||||
@@ -0,0 +1,9 @@
|
||||
function formatEntireFile(
|
||||
fileVersion: FileVersion,
|
||||
range: atom$Range,
|
||||
): Promise<?{
|
||||
newCursor?: number,
|
||||
formatted: string,
|
||||
}> {}
|
||||
|
||||
function foo(): Promise<?boolean> {}
|
||||
Reference in new issue
Block a user