fix(es/quote): Fix code generation of AssignTarget (#8604)

This commit is contained in:
Donny/강동윤 2024-02-05 20:25:09 +09:00 committed by GitHub
parent ae6debdcb3
commit 16e9d4ca31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
use swc_ecma_ast::*;
impl_enum!(AssignTarget, [Simple, Pat]);
impl_enum!(AssignTarget, [Simple, Pat], true);
impl_enum!(
SimpleAssignTarget,
[

View File

@ -42,7 +42,7 @@ macro_rules! impl_enum {
($E:ident, [ $($v:ident),* ], true) => {
impl crate::ast::ToCode for $E {
fn to_code(&self, cx: &crate::ctxt::Ctx) -> syn::Expr {
if let Self::Ident(i) = self {
if let Some(i) = self.as_ident() {
if let Some(var_name) = i.sym.strip_prefix('$') {
if let Some(var) = cx.var(crate::ctxt::VarPos::$E, var_name) {
return var.get_expr();