Skip to content

Commit ae75664

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
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: #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
1 parent 64ebe5b commit ae75664

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/babel-plugin-codegen/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ module.exports = function ({parse, types: t}) {
8686

8787
if (firstDeclaration.type === 'VariableDeclarator') {
8888
if (
89+
firstDeclaration.init &&
8990
firstDeclaration.init.type === 'CallExpression' &&
9091
firstDeclaration.init.callee.type === 'Identifier' &&
9192
firstDeclaration.init.callee.name === 'codegenNativeCommands'

0 commit comments

Comments
 (0)