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
This commit is contained in:
Nicholas Young 2016-11-23 09:27:36 -08:00 committed by Facebook Github Bot
parent 6fef014295
commit 2121527cb8

View File

@ -24,12 +24,12 @@ module.exports = function symbolMember(babel) {
return { return {
visitor: { visitor: {
MemberExpression(path) { MemberExpression(path) {
let node = path.node; if (!isAppropriateMember(path)) {
if (!isAppropriateMember(node)) {
return; return;
} }
let node = path.node;
path.replaceWith( path.replaceWith(
t.conditionalExpression( t.conditionalExpression(
t.binaryExpression( t.binaryExpression(
@ -54,8 +54,11 @@ module.exports = function symbolMember(babel) {
}; };
}; };
function isAppropriateMember(node) { function isAppropriateMember(path) {
return node.object.type === 'Identifier' && let node = path.node;
return path.parentPath.type !== 'AssignmentExpression' &&
node.object.type === 'Identifier' &&
node.object.name === 'Symbol' && node.object.name === 'Symbol' &&
node.property.type === 'Identifier'; node.property.type === 'Identifier';
} }