Fix generator missing parens on Flow union types (#6334)
This commit is contained in:
parent
f0ab0f81d3
commit
832408e85d
@ -93,6 +93,17 @@ export function Binary(node: Object, parent: Object): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function UnionTypeAnnotation(node: Object, parent: Object): boolean {
|
||||||
|
return (
|
||||||
|
t.isArrayTypeAnnotation(parent) ||
|
||||||
|
t.isNullableTypeAnnotation(parent) ||
|
||||||
|
t.isIntersectionTypeAnnotation(parent) ||
|
||||||
|
t.isUnionTypeAnnotation(parent)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { UnionTypeAnnotation as IntersectionTypeAnnotation };
|
||||||
|
|
||||||
export function TSAsExpression() {
|
export function TSAsExpression() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
10
packages/babel-generator/test/fixtures/flow/type-union-intersection/actual.js
vendored
Normal file
10
packages/babel-generator/test/fixtures/flow/type-union-intersection/actual.js
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type foo = ?(a | b);
|
||||||
|
type foo2 = ?(a & b);
|
||||||
|
type foo3 = (a | b)[];
|
||||||
|
type foo4 = (a & b)[];
|
||||||
|
type foo5 = a | b | c;
|
||||||
|
type foo6 = a & b & c;
|
||||||
|
type foo7 = a & b | c;
|
||||||
|
type foo8 = a | b & c;
|
||||||
|
type foo9 = a & (b | c);
|
||||||
|
type foo10 = (a | b) & c;
|
||||||
10
packages/babel-generator/test/fixtures/flow/type-union-intersection/expected.js
vendored
Normal file
10
packages/babel-generator/test/fixtures/flow/type-union-intersection/expected.js
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type foo = ?(a | b);
|
||||||
|
type foo2 = ?(a & b);
|
||||||
|
type foo3 = (a | b)[];
|
||||||
|
type foo4 = (a & b)[];
|
||||||
|
type foo5 = a | b | c;
|
||||||
|
type foo6 = a & b & c;
|
||||||
|
type foo7 = (a & b) | c;
|
||||||
|
type foo8 = a | (b & c);
|
||||||
|
type foo9 = a & (b | c);
|
||||||
|
type foo10 = (a | b) & c;
|
||||||
@ -1017,9 +1017,9 @@ babylon@7.0.0-beta.18:
|
|||||||
version "7.0.0-beta.18"
|
version "7.0.0-beta.18"
|
||||||
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.18.tgz#5c23ee3fdb66358aabf3789779319c5b78a233c7"
|
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.18.tgz#5c23ee3fdb66358aabf3789779319c5b78a233c7"
|
||||||
|
|
||||||
babylon@7.0.0-beta.25:
|
babylon@7.0.0-beta.26:
|
||||||
version "7.0.0-beta.25"
|
version "7.0.0-beta.26"
|
||||||
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.25.tgz#5fff5062b7082203b1bc5cab488e154cfee0202a"
|
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.26.tgz#afc2c6b86113d000cc9476fd6f73e2a9223de8f7"
|
||||||
|
|
||||||
babylon@^6.17.4, babylon@^6.18.0:
|
babylon@^6.17.4, babylon@^6.18.0:
|
||||||
version "6.18.0"
|
version "6.18.0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user