Skip to content

Commit

Permalink
Fix transform of delete a?.b in function params
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jul 3, 2023
1 parent c53e5a0 commit 8cb9a43
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Expand Up @@ -68,7 +68,9 @@ export function transformOptionalChain(
// Replace `function (a, x = a.b?.c) {}` to `function (a, x = (() => a.b?.c)() ){}`
// so the temporary variable can be injected in correct scope
if (scope.path.isPattern() && needsMemoize(path)) {
path.replaceWith(template.ast`(() => ${path.node})()` as t.Statement);
replacementPath.replaceWith(
template.expression.ast`(() => ${replacementPath.node})()`,
);
// The injected optional chain will be queued and eventually transformed when visited
return;
}
Expand Down
@@ -0,0 +1 @@
function f(x = delete a()?.b) {}
@@ -0,0 +1,4 @@
function f(x = (() => {
var _a;
return (_a = a()) === null || _a === void 0 ? true : delete _a.b;
})()) {}

0 comments on commit 8cb9a43

Please sign in to comment.