Fix generator missing parens on Flow union types (#6334)

This commit is contained in:
Brian Ng 2017-09-29 13:43:38 -05:00 committed by Henry Zhu
parent f0ab0f81d3
commit 832408e85d
4 changed files with 34 additions and 3 deletions

View File

@ -93,6 +93,17 @@ export function Binary(node: Object, parent: Object): boolean {
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() {
return true;
}

View 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;

View 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;

View File

@ -1017,9 +1017,9 @@ babylon@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"
babylon@7.0.0-beta.25:
version "7.0.0-beta.25"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.25.tgz#5fff5062b7082203b1bc5cab488e154cfee0202a"
babylon@7.0.0-beta.26:
version "7.0.0-beta.26"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.26.tgz#afc2c6b86113d000cc9476fd6f73e2a9223de8f7"
babylon@^6.17.4, babylon@^6.18.0:
version "6.18.0"