react-native-macos/packages/babel-plugin-codegen
Janic Duplessis ae756647c9 Fix babel-plugin-codegen crash when export init is null (#33387)
Summary:
It is possible that `init` is null when using the following code.

```js
export var a;
```

The typescript compiler actually generates something like this for enums so a lot of third party libraries triggered this issue.

For example in expo-apple-authentication/build/AppleAuthentication.types.js

```js
export var AppleAuthenticationScope;
(function (AppleAuthenticationScope) {
    AppleAuthenticationScope[AppleAuthenticationScope["FULL_NAME"] = 0] = "FULL_NAME";
    AppleAuthenticationScope[AppleAuthenticationScope["EMAIL"] = 1] = "EMAIL";
})(AppleAuthenticationScope || (AppleAuthenticationScope = {}));
```

This simply adds a null check.

## Changelog

[General] [Fixed] - Fix babel-plugin-codegen crash when export init is null

Pull Request resolved: https://github.com/facebook/react-native/pull/33387

Test Plan: Tested that this fixed the crash in an app.

Reviewed By: javache

Differential Revision: D34687271

Pulled By: philIip

fbshipit-source-id: 7a7e0fe1bb6a7a21a5b442af26b221a263d4173d
2022-03-11 23:24:22 -08:00
..
__test_fixtures__ Update copyright headers from Facebook to Meta 2021-12-30 15:11:21 -08:00
__tests__ Re-introduce {eventName}: true ViewConfig ValidAttributes in Static ViewConfigs 2022-02-08 19:11:08 -08:00
BUCK Rename babel-plugin-inline-view-configs to @react-native/babel-plugin-codegen 2020-07-31 13:00:50 -07:00
index.js Fix babel-plugin-codegen crash when export init is null (#33387) 2022-03-11 23:24:22 -08:00
package.json Add babel-plugin-codegen to babel.config.js for fabric (#32756) 2021-12-14 19:28:41 -08:00