New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding createFlowUnionType in place of createUnionTypeAnnotation without breaking change #11448
Conversation
* ➕ add test fixture * ➕ add removeTypeDuplicates for typescript * ➕ add createTSUnionType for typescript * 💊 fix ConditionalExpression for typescript * 💊 fix ConditionalExpression * 💊 fix added test case * ➕ add new line at the end of the file * 💊 types.every(f) => f(types[0]) * 🔄 bug => foo * ➕ add TSBaseType * ➕ add conditions NOT to break backward compatibility
@@ -99,6 +99,10 @@ function getTypeAnnotationBindingConstantViolations(binding, path, name) { | |||
return t.createTSUnionType(types); | |||
} | |||
|
|||
if (t.createFlowUnionType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if it's available (in new versions only)
Old version will go further
The same for other cases below
@@ -128,6 +128,8 @@ lines.push( | |||
`declare function createTypeAnnotationBasedOnTypeof(type: 'string' | 'number' | 'undefined' | 'boolean' | 'function' | 'object' | 'symbol'): ${NODE_PREFIX}TypeAnnotation`, | |||
// eslint-disable-next-line max-len | |||
`declare function createUnionTypeAnnotation(types: Array<${NODE_PREFIX}FlowType>): ${NODE_PREFIX}UnionTypeAnnotation`, | |||
// eslint-disable-next-line max-len | |||
`declare function createFlowUnionType(types: Array<${NODE_PREFIX}FlowType>): ${NODE_PREFIX}UnionTypeAnnotation`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not removing old declaration, adding the new one
same below
packages/babel-types/src/builders/flow/createUnionTypeAnnotation.js
Outdated
Show resolved
Hide resolved
@nicolo-ribaudo is something wrong with test coverage and other tests or did I break anything? I see changes in |
Yeah, it's the codecov integration which is buggy. |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/21214/ |
@Beraliv Would you like to open a PR to the I'm merging |
Sure, will be ready this night! |
Adding new Flow function
createFlowUnionType
which is more descriptive thancreateUnionTypeAnnotation
However, I save
createUnionTypeAnnotation
for backward compatibility (it can be deleted in any major release, I can add TODO if needed)Connected to changes in #11378