Skip to content

Conversation

@arushikesarwani94
Copy link
Contributor

Summary:
Previously, the parser was mapping to Array when the element types of union were different. This caused compat checker to not recognize changes in unions of different types.

StringLiteralUnionTypeAnnotation already had support for types, that can be expanded to all Union types so as to incorporate the Unions of different types.

{
  type: 'StringLiteralUnionTypeAnnotation',
  types: [
    {
      type: 'StringLiteralTypeAnnotation'
      value: 'light'
    },
    {
      type: 'StringLiteralTypeAnnotation'
      value: 'dark'
    },
  ],
}

NOTE: Generators behavior still remain unchanged hence don't allow unions of different types. Only RN Compat Checker consumes this.

The value of this is that the compat checker can now error when the union of different types changes.

Changelog: [Internal]

Differential Revision: D86501597

@meta-codesync
Copy link

meta-codesync bot commented Nov 11, 2025

@arushikesarwani94 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D86501597.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 11, 2025
Summary:
Pull Request resolved: facebook#54489

Previously, the parser was mapping to Array<any> when the element types of union were different. This caused compat checker to not recognize changes in unions of different types.

`StringLiteralUnionTypeAnnotation`  already had support for `types`, that can be expanded to all Union types so as to incorporate the Unions of different types.
```
{
  type: 'StringLiteralUnionTypeAnnotation',
  types: [
    {
      type: 'StringLiteralTypeAnnotation'
      value: 'light'
    },
    {
      type: 'StringLiteralTypeAnnotation'
      value: 'dark'
    },
  ],
}
```

NOTE: Generators behavior still remain unchanged hence don't allow unions of different types. Only RN Compat Checker consumes this.

The value of this is that the compat checker can now error when the union of different types changes.
Also for consistency added support for similar literal types for Number & Boolean i.e `NumberLiteralTypeAnnotation` & `BooleanLiteralTypeAnnotation`

Changelog: [Internal]

Differential Revision: D86501597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants