Don't call shouldHugType for function arguments, fixes #2458 (#2496)

master
Lucas Azzola 2017-07-16 19:53:01 +10:00 committed by Christopher Chedeau
parent 028d9e0ea7
commit 188c466cd5
5 changed files with 92 additions and 3 deletions

View File

@ -4779,7 +4779,7 @@ function isNodeStartingWithDeclare(node, options) {
}
function shouldHugType(node) {
if (node.type === "ObjectTypeAnnotation" || node.type === "TSTypeLiteral") {
if (isObjectType(node)) {
return true;
}
@ -4805,6 +4805,7 @@ function shouldHugType(node) {
return true;
}
}
return false;
}
@ -4818,9 +4819,9 @@ function shouldHugArguments(fun) {
(fun.params[0].type === "Identifier" &&
fun.params[0].typeAnnotation &&
fun.params[0].typeAnnotation.type === "TypeAnnotation" &&
shouldHugType(fun.params[0].typeAnnotation.typeAnnotation)) ||
isObjectType(fun.params[0].typeAnnotation.typeAnnotation)) ||
(fun.params[0].type === "FunctionTypeParam" &&
shouldHugType(fun.params[0].typeAnnotation))) &&
isObjectType(fun.params[0].typeAnnotation))) &&
!fun.rest
);
}

View File

@ -14,6 +14,19 @@ interface RelayProps {
}
export function aPrettyLongFunction(aRatherLongParamName: string | null): string {}
export function aPrettyLongFunctionA(aRatherLongParameterName: {} | null): string[] {}
export function aPrettyLongFunctionB(aRatherLongParameterName: Function | null): string[] {}
export interface MyInterface {}
export function aPrettyLongFunctionC(aRatherLongParameterName: MyInterface | null): string[] {}
export type MyType = MyInterface
export function aPrettyLongFunctionD(aRatherLongParameterName: MyType | null): string[] {}
export function aShortFn(aShortParmName: MyType | null): string[] {}
export function aPrettyLongFunctionE(aRatherLongParameterName: Array<{
__id: string,
} | null> | null | void): string[] {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
interface RelayProps {
articles:
@ -35,4 +48,27 @@ export function aPrettyLongFunction(
aRatherLongParamName: string | null
): string {}
export function aPrettyLongFunctionA(
aRatherLongParameterName: {} | null
): string[] {}
export function aPrettyLongFunctionB(
aRatherLongParameterName: Function | null
): string[] {}
export interface MyInterface {}
export function aPrettyLongFunctionC(
aRatherLongParameterName: MyInterface | null
): string[] {}
export type MyType = MyInterface;
export function aPrettyLongFunctionD(
aRatherLongParameterName: MyType | null
): string[] {}
export function aShortFn(aShortParmName: MyType | null): string[] {}
export function aPrettyLongFunctionE(
aRatherLongParameterName: Array<{
__id: string
} | null> | null | void
): string[] {}
`;

View File

@ -11,3 +11,16 @@ interface RelayProps {
}
export function aPrettyLongFunction(aRatherLongParamName: string | null): string {}
export function aPrettyLongFunctionA(aRatherLongParameterName: {} | null): string[] {}
export function aPrettyLongFunctionB(aRatherLongParameterName: Function | null): string[] {}
export interface MyInterface {}
export function aPrettyLongFunctionC(aRatherLongParameterName: MyInterface | null): string[] {}
export type MyType = MyInterface
export function aPrettyLongFunctionD(aRatherLongParameterName: MyType | null): string[] {}
export function aShortFn(aShortParmName: MyType | null): string[] {}
export function aPrettyLongFunctionE(aRatherLongParameterName: Array<{
__id: string,
} | null> | null | void): string[] {}

View File

@ -14,6 +14,19 @@ function StatelessFunctionalComponent({
return <div />
}
function StatelessFunctionalComponent({
isActive,
onFiltersUpdated,
onSelect,
onSubmitAndDeselect,
onCancel,
searchFilters,
title,
items,
}: MyType | null | void) {
return <div />
}
const StatelessFunctionalComponent = ({
isActive,
onFiltersUpdated,
@ -80,6 +93,19 @@ function StatelessFunctionalComponent({
return <div />;
}
function StatelessFunctionalComponent({
isActive,
onFiltersUpdated,
onSelect,
onSubmitAndDeselect,
onCancel,
searchFilters,
title,
items
}: MyType | null | void) {
return <div />;
}
const StatelessFunctionalComponent = ({
isActive,
onFiltersUpdated,

View File

@ -11,6 +11,19 @@ function StatelessFunctionalComponent({
return <div />
}
function StatelessFunctionalComponent({
isActive,
onFiltersUpdated,
onSelect,
onSubmitAndDeselect,
onCancel,
searchFilters,
title,
items,
}: MyType | null | void) {
return <div />
}
const StatelessFunctionalComponent = ({
isActive,
onFiltersUpdated,