Fix flow babel-generator function parantheses (#9523)
This commit is contained in:
parent
058f057426
commit
5bb1bb080f
@ -35,7 +35,16 @@ export function NullableTypeAnnotation(node: Object, parent: Object): boolean {
|
|||||||
return t.isArrayTypeAnnotation(parent);
|
return t.isArrayTypeAnnotation(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { NullableTypeAnnotation as FunctionTypeAnnotation };
|
export function FunctionTypeAnnotation(node: Object, parent: Object): boolean {
|
||||||
|
return (
|
||||||
|
// (() => A) | (() => B)
|
||||||
|
t.isUnionTypeAnnotation(parent) ||
|
||||||
|
// (() => A) & (() => B)
|
||||||
|
t.isIntersectionTypeAnnotation(parent) ||
|
||||||
|
// (() => A)[]
|
||||||
|
t.isArrayTypeAnnotation(parent)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function UpdateExpression(node: Object, parent: Object): boolean {
|
export function UpdateExpression(node: Object, parent: Object): boolean {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -7,4 +7,4 @@ opaque type union = {
|
|||||||
} | {
|
} | {
|
||||||
type: "B"
|
type: "B"
|
||||||
};
|
};
|
||||||
opaque type overloads = (x: string) => number & (x: number) => string;
|
opaque type overloads = ((x: string) => number) & ((x: number) => string);
|
||||||
3
packages/babel-generator/test/fixtures/flow/parantheses/input.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/flow/parantheses/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
type A = (<T>(T) => $Foo<T>) & (<T>(T) => $Foo<T>);
|
||||||
|
type B = (<T>(T) => $Foo<T>) | (<T>(T) => $Foo<T>);
|
||||||
|
type C = (<T>(T) => $Foo<T>)[];
|
||||||
3
packages/babel-generator/test/fixtures/flow/parantheses/output.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/flow/parantheses/output.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
type A = (<T>(T) => $Foo<T>) & (<T>(T) => $Foo<T>);
|
||||||
|
type B = (<T>(T) => $Foo<T>) | (<T>(T) => $Foo<T>);
|
||||||
|
type C = (<T>(T) => $Foo<T>)[];
|
||||||
@ -7,6 +7,6 @@ type union = {
|
|||||||
} | {
|
} | {
|
||||||
type: "B"
|
type: "B"
|
||||||
};
|
};
|
||||||
type overloads = (x: string) => number & (x: number) => string;
|
type overloads = ((x: string) => number) & ((x: number) => string);
|
||||||
type func = (string) => string;
|
type func = (string) => string;
|
||||||
type D = X.Y<Z>;
|
type D = X.Y<Z>;
|
||||||
@ -180,7 +180,7 @@ class Array {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var x: () => number | () => string = fn;
|
var x: () => number | (() => string) = fn;
|
||||||
var x: typeof Y = Y;
|
var x: typeof Y = Y;
|
||||||
var x: typeof Y | number = Y;
|
var x: typeof Y | number = Y;
|
||||||
var {
|
var {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user