Fix union type in FunctionTypeParam without name (#19397)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
8dd5cc2d02
commit
3751f82fc6
7 files changed
+221
-13
No files matched your search
@@ -97,7 +97,11 @@ function shouldIndentUnionType(path) {
|
||||
(key === "elementTypes" && isTupleType(parent)) ||
|
||||
((key === "trueType" || key === "falseType") &&
|
||||
isConditionalType(parent)) ||
|
||||
(key === "params" && isTypeParameterInstantiation(parent))
|
||||
(key === "params" && isTypeParameterInstantiation(parent)) ||
|
||||
(key === "typeAnnotation" &&
|
||||
parent.type === "FunctionTypeParam" &&
|
||||
!parent.name &&
|
||||
path.grandparent.this !== parent)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,32 +176,54 @@ trailingComma: "all"
|
||||
=====================================input======================================
|
||||
// @flow
|
||||
|
||||
type A = (
|
||||
this: | SupperLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
type A1 = (
|
||||
this: | SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean;
|
||||
|
||||
type B = (
|
||||
_this: | SupperLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
type A2 = (
|
||||
_this: | SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean
|
||||
|
||||
type A3 = (
|
||||
| SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean
|
||||
|
||||
type A4 = (
|
||||
/* this: */ | SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean
|
||||
|
||||
=====================================output=====================================
|
||||
// @flow
|
||||
|
||||
type A = (
|
||||
type A1 = (
|
||||
this:
|
||||
| SupperLongLongLongLongLongLongLongLongLongLongLongType
|
||||
| SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType
|
||||
| FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean;
|
||||
|
||||
type B = (
|
||||
type A2 = (
|
||||
_this:
|
||||
| SupperLongLongLongLongLongLongLongLongLongLongLongType
|
||||
| SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType
|
||||
| FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean;
|
||||
|
||||
type A3 = (
|
||||
| SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType
|
||||
| FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean;
|
||||
|
||||
type A4 = (
|
||||
/* this: */ | SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType
|
||||
| FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean;
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -1,11 +1,21 @@
|
||||
// @flow
|
||||
|
||||
type A = (
|
||||
this: | SupperLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
type A1 = (
|
||||
this: | SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean;
|
||||
|
||||
type B = (
|
||||
_this: | SupperLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
type A2 = (
|
||||
_this: | SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean
|
||||
|
||||
type A3 = (
|
||||
| SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean
|
||||
|
||||
type A4 = (
|
||||
/* this: */ | SupperLongLongLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
|
||||
b: number,
|
||||
) => boolean
|
||||
@@ -22,6 +22,85 @@ const myValue = (callcallcallcallcallcall(
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`function-type-param.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["flow"]
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
type a1 = (
|
||||
| {//
|
||||
}
|
||||
| {//
|
||||
},
|
||||
) => void
|
||||
|
||||
type a2 = (
|
||||
// Comment
|
||||
| {//
|
||||
}
|
||||
| {//
|
||||
},
|
||||
) => void
|
||||
|
||||
hook useRefetchFunction(
|
||||
dispatch: (
|
||||
| {
|
||||
environment: IEnvironment,
|
||||
fragmentIdentifier: string,
|
||||
type: 'reset',
|
||||
}
|
||||
| {
|
||||
fetchPolicy?: FetchPolicy,
|
||||
onComplete?: (Error | null) => void,
|
||||
refetchEnvironment: ?IEnvironment,
|
||||
refetchQuery: OperationDescriptor,
|
||||
renderPolicy?: RenderPolicy,
|
||||
type: 'refetch',
|
||||
},
|
||||
) => void,
|
||||
) {}
|
||||
|
||||
=====================================output=====================================
|
||||
type a1 = (
|
||||
| {
|
||||
//
|
||||
}
|
||||
| {
|
||||
//
|
||||
},
|
||||
) => void;
|
||||
|
||||
type a2 = (
|
||||
// Comment
|
||||
| {
|
||||
//
|
||||
}
|
||||
| {
|
||||
//
|
||||
},
|
||||
) => void;
|
||||
|
||||
hook useRefetchFunction(
|
||||
dispatch: (
|
||||
| {
|
||||
environment: IEnvironment,
|
||||
fragmentIdentifier: string,
|
||||
type: "reset",
|
||||
}
|
||||
| {
|
||||
fetchPolicy?: FetchPolicy,
|
||||
onComplete?: (Error | null) => void,
|
||||
refetchEnvironment: ?IEnvironment,
|
||||
refetchQuery: OperationDescriptor,
|
||||
renderPolicy?: RenderPolicy,
|
||||
type: "refetch",
|
||||
},
|
||||
) => void,
|
||||
) {}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-1197-2.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["flow"]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
type a1 = (
|
||||
| {//
|
||||
}
|
||||
| {//
|
||||
},
|
||||
) => void
|
||||
|
||||
type a2 = (
|
||||
// Comment
|
||||
| {//
|
||||
}
|
||||
| {//
|
||||
},
|
||||
) => void
|
||||
|
||||
hook useRefetchFunction(
|
||||
dispatch: (
|
||||
| {
|
||||
environment: IEnvironment,
|
||||
fragmentIdentifier: string,
|
||||
type: 'reset',
|
||||
}
|
||||
| {
|
||||
fetchPolicy?: FetchPolicy,
|
||||
onComplete?: (Error | null) => void,
|
||||
refetchEnvironment: ?IEnvironment,
|
||||
refetchQuery: OperationDescriptor,
|
||||
renderPolicy?: RenderPolicy,
|
||||
type: 'refetch',
|
||||
},
|
||||
) => void,
|
||||
) {}
|
||||
@@ -257,6 +257,52 @@ type A = T extends "arrow"
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`function-type-param.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript", "flow"]
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
type a1 = (
|
||||
a: | {//
|
||||
}
|
||||
| {//
|
||||
},
|
||||
) => void
|
||||
|
||||
type a2 = (
|
||||
a:
|
||||
// Comment
|
||||
| {//
|
||||
}
|
||||
| {//
|
||||
},
|
||||
) => void
|
||||
|
||||
=====================================output=====================================
|
||||
type a1 = (
|
||||
a:
|
||||
| {
|
||||
//
|
||||
}
|
||||
| {
|
||||
//
|
||||
},
|
||||
) => void;
|
||||
|
||||
type a2 = (
|
||||
a:
|
||||
// Comment
|
||||
| {
|
||||
//
|
||||
}
|
||||
| {
|
||||
//
|
||||
},
|
||||
) => void;
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`in-tuple.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript", "flow"]
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
type a1 = (
|
||||
a: | {//
|
||||
}
|
||||
| {//
|
||||
},
|
||||
) => void
|
||||
|
||||
type a2 = (
|
||||
a:
|
||||
// Comment
|
||||
| {//
|
||||
}
|
||||
| {//
|
||||
},
|
||||
) => void
|
||||
Reference in new issue
Block a user