Skip to content

Commit

Permalink
Requeue parent path after processing optionals
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism committed Nov 23, 2020
1 parent 2b13863 commit 556d7c0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/babel-plugin-proposal-optional-chaining/src/index.js
Expand Up @@ -111,6 +111,9 @@ export default declare((api, options) => {
replacementPath = parentPath;
isDeleteOperation = true;
}

let needsRequeue = false;

for (let i = optionals.length - 1; i >= 0; i--) {
const node = optionals[i];

Expand Down Expand Up @@ -237,6 +240,12 @@ export default declare((api, options) => {
replacementPath.get("alternate"),
);
}

needsRequeue = true;
}

if (needsRequeue) {
parentPath.requeue();
}
},
},
Expand Down
@@ -0,0 +1,2 @@
const a = 1;
const b = () => a?.b?.c!.d;
@@ -0,0 +1,3 @@
{
"plugins": ["transform-typescript", "proposal-optional-chaining"]
}
@@ -0,0 +1,7 @@
const a = 1;

const b = () => {
var _a$b;

return a === null || a === void 0 ? void 0 : (_a$b = a.b) === null || _a$b === void 0 ? void 0 : _a$b.c.d;
};

0 comments on commit 556d7c0

Please sign in to comment.