Files
react-native/packages/react-native-compatibility-check/src
Eli White 69ccbc3943 Allow union changes when the new element is in the middle of the union (#50117)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50117

D70870978 failed the compat check because it modified a union by removing an element in the middle:

```
'global' | 'self'
```

from
```
'global' | 'application' | 'self'
```

This caused the compat check to complain that index 1 in both unions: `self` didn't match `application` and thus it was a type incompatibility.

We should have been comparing these as an unsorted array of options, which first sorts, then treats differences as added/removed elements instead of incompatbile elements.

If in the example above the removed element was the last one from the union, it would have been fine.

Once these are classified as added/removed, the VersionDiffer is able to check whether that change is allowed in fromNative or toNative.

Changelog: [General][Fixed] Compatibility Check: Allow union changes when the new element is in the middle of the union

Reviewed By: makovkastar

Differential Revision: D71433054

fbshipit-source-id: 20a73f0ba0576daf30cec97bae969b31baf7f468
2025-03-19 11:33:08 -07:00
..