Skip to content
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

Merged
merged 3 commits into from Apr 22, 2020
Merged

Conversation

Beraliv
Copy link
Contributor

@Beraliv Beraliv commented Apr 20, 2020

Q                       A
Fixed Issues? Fixes #11378 (comment)
Patch: Bug Fix? No
Major: Breaking Change? No
Minor: New Feature? Yes (technically)
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? No
License MIT

Adding new Flow function createFlowUnionType which is more descriptive than createUnionTypeAnnotation

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

@Beraliv Beraliv changed the title Flow union type fix Adding createFlowUnionType in place of createUnionTypeAnnotation without breaking change Apr 20, 2020
Beraliv referenced this pull request Apr 20, 2020
* ➕ 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) {
Copy link
Contributor Author

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`,
Copy link
Contributor Author

@Beraliv Beraliv Apr 20, 2020

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

@existentialism existentialism added area: flow pkg: types PR: New Feature 🚀 A type of pull request used for our changelog categories labels Apr 20, 2020
@Beraliv
Copy link
Contributor Author

Beraliv commented Apr 21, 2020

@nicolo-ribaudo is something wrong with test coverage and other tests or did I break anything?

I see changes in _interopRequireWildcard, is it connected with the PR?

@nicolo-ribaudo
Copy link
Member

Yeah, it's the codecov integration which is buggy.

@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/21214/

@nicolo-ribaudo nicolo-ribaudo merged commit a34424a into babel:master Apr 22, 2020
@nicolo-ribaudo
Copy link
Member

@Beraliv Would you like to open a PR to the next-8-dev (Babel 8) branch removing the checks needed for compatibility with Babel 7?

I'm merging master in next-8-dev right now.

@Beraliv
Copy link
Contributor Author

Beraliv commented Apr 22, 2020

@Beraliv Would you like to open a PR to the next-8-dev (Babel 8) branch removing the checks needed for compatibility with Babel 7?

I'm merging master in next-8-dev right now.

Sure, will be ready this night!

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 23, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: flow outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: types PR: New Feature 🚀 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants