Skip to content

Commit 44f7353

Browse files
committed
[scramjet] handle string literals in binding patterns properly
1 parent f31ac68 commit 44f7353

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/scramjet/rewriter/js/src/visitor.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,16 @@ where
302302
}
303303
}
304304
}
305+
PropertyKey::StringLiteral(id) => {
306+
// const { "location": x } = self;
307+
// this cannot be shorthand, so we can use the easy path
308+
if UNSAFE_GLOBALS.contains(&id.value.to_string().as_str()) {
309+
self.jschanges.add(rewrite!(
310+
id.span.shrink(1),
311+
RewriteProperty { ident: id.value }
312+
));
313+
}
314+
}
305315
PropertyKey::PrivateIdentifier(_) => {
306316
// doesn't matter
307317
}

0 commit comments

Comments
 (0)