PR comments

This commit is contained in:
Justin Ridgewell
2017-06-05 22:53:24 -04:00
parent faa6c9f708
commit d92309f0db
4 changed files with 22 additions and 5 deletions

View File

@@ -6,14 +6,11 @@ export default function ({ types: t }) {
const optionals = [path.node];
const nil = scope.buildUndefinedNode();
let objectPath = path.get(key);
while (objectPath.isMemberExpression()) {
for (let objectPath = path.get(key); objectPath.isMemberExpression(); objectPath = objectPath.get("object")) {
const { node } = objectPath;
if (node.optional) {
optionals.push(node);
}
objectPath = objectPath.get("object");
}
for (let i = optionals.length - 1; i >= 0; i--) {