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
[babel 8] ObjectTypeAnnotation
fields must always be arrays
#14465
Conversation
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.
The changes look good to me. BABEL_TYPES_8_BREAKING
is superseded by BABEL_8_BREAKING
, so the latter should be good to go.
82ad2f2
to
5d5202f
Compare
Ok, I put all the changes behind the flag. Is there a document where all breaking changes/migrations steps are recorded? |
…are always present BREAKING CHANGE: The 2., 3., and 4. parameter to the builder for `ObjectTypeAnnotation` do not accept null anymore. Use undefined.
5d5202f
to
4882ccc
Compare
Yes, see #10746. |
ObjectTypeAnnotation
are always presentObjectTypeAnnotation
fields must always be arrays
@danez Even if something is not tracked in this issue (for example, this PR is a very small breaking change), we are marking all these changes with the same label so that we can go through them when preparing Babel 8. |
Ok cool. |
The fields
indexers
,callProperties
, andinternalSlots
in the nodeObjectTypeAnnotation
are currently marked as optional. This is correct for the builder, they should be optional there.For the TS types, this is not quite correct, because the babel parser always initializes these fields with empty arrays (https://github.com/babel/babel/blob/main/packages/babel-parser/src/plugins/flow/index.js#L1085-L1088).
The only way to set these fields to null is with the builder currently.
The change here is to not mark these fields as optional but instead provide an empty array as a default value. This way the builder still has these params as optional, but cannot be set to
null
anymore.The Typescript types on the other hand now do not mark these fields as optional which is correct, as they are always an array, even if it might be empty.
Do you think this is a reasonable change?
Now, is this breaking? Only the builder might be considered as a breaking change, as it does not allownull
anymore for these fields (see change generator tests). If you think this is breaking enough I could move that behind the BABEL8 flag. Please let me know.After thinking about this a little more I now think this should be considered breaking. Which Flag should I use?
BABEL_TYPES_8_BREAKING
orBABEL_8_BREAKING