Adding createFlowUnionType in place of createUnionTypeAnnotati… (#11448)

* 🔄 createUnionTypeAnnotation => createFlowUnionType

*  add createFlowUnionType if it exists (in new versions only ⚠️)

* 🔄 use createFlowUnionType for createUnionTypeAnnotation
This commit is contained in:
beraliv
2020-04-22 20:11:01 +03:00
committed by GitHub
parent 928b9f8c95
commit a34424a894
6 changed files with 26 additions and 4 deletions

View File

@@ -99,6 +99,10 @@ function getTypeAnnotationBindingConstantViolations(binding, path, name) {
return t.createTSUnionType(types);
}
if (t.createFlowUnionType) {
return t.createFlowUnionType(types);
}
return t.createUnionTypeAnnotation(types);
}
@@ -214,6 +218,13 @@ function getConditionalAnnotation(binding, path, name) {
};
}
if (t.createFlowUnionType) {
return {
typeAnnotation: t.createFlowUnionType(types),
ifStatement,
};
}
return {
typeAnnotation: t.createUnionTypeAnnotation(types),
ifStatement,