From 2121527cb87e5cef52196fa49d345e2e5d022b06 Mon Sep 17 00:00:00 2001 From: Nicholas Young Date: Wed, 23 Nov 2016 09:27:36 -0800 Subject: [PATCH] Update babel-preset, filter path by identifiers. Summary: This PR contains [the fix](https://github.com/facebook/react-native/issues/6063#issuecomment-189416771) from #6063, which resolves the issue with rxjs 5. Is there a reason to not include these proposed changes in the repo? Closes https://github.com/facebook/react-native/pull/10815 Differential Revision: D4226835 fbshipit-source-id: bfaeaebbe308c45bce814469ef0f75283f050d18 --- babel-preset/transforms/transform-symbol-member.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/babel-preset/transforms/transform-symbol-member.js b/babel-preset/transforms/transform-symbol-member.js index 305eb3c2d..5962918dc 100644 --- a/babel-preset/transforms/transform-symbol-member.js +++ b/babel-preset/transforms/transform-symbol-member.js @@ -24,12 +24,12 @@ module.exports = function symbolMember(babel) { return { visitor: { MemberExpression(path) { - let node = path.node; - - if (!isAppropriateMember(node)) { + if (!isAppropriateMember(path)) { return; } + let node = path.node; + path.replaceWith( t.conditionalExpression( t.binaryExpression( @@ -54,8 +54,11 @@ module.exports = function symbolMember(babel) { }; }; -function isAppropriateMember(node) { - return node.object.type === 'Identifier' && +function isAppropriateMember(path) { + let node = path.node; + + return path.parentPath.type !== 'AssignmentExpression' && + node.object.type === 'Identifier' && node.object.name === 'Symbol' && node.property.type === 'Identifier'; }