Skip to content

Commit

Permalink
Update babel-preset, filter path by identifiers.
Browse files Browse the repository at this point in the history
Summary:
This PR contains [the fix](#6063 (comment)) from #6063, which resolves the issue with rxjs 5. Is there a reason to not include these proposed changes in the repo?
Closes #10815

Differential Revision: D4226835

fbshipit-source-id: bfaeaebbe308c45bce814469ef0f75283f050d18
  • Loading branch information
Nicholas Young authored and Facebook Github Bot committed Nov 23, 2016
1 parent 6fef014 commit 2121527
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions babel-preset/transforms/transform-symbol-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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';
}

0 comments on commit 2121527

Please sign in to comment.