Skip to content

Commit

Permalink
fix: import equals var kind
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Jul 21, 2023
1 parent e76d938 commit 4aeefd0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/swc_ecma_transforms_typescript/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ impl Transform {
}

fn visit_mut_module_items_for_import_equals(&mut self, n: &mut [ModuleItem]) {
let var_kind = if self.namespace_id.is_some() {
VarDeclKind::Const
} else {
VarDeclKind::Var
};

for module_item in n.iter_mut() {
match module_item {
ModuleItem::ModuleDecl(ModuleDecl::TsImportEquals(v))
Expand All @@ -401,7 +407,7 @@ impl Transform {
};

let init = Self::ts_entity_name_to_expr(ts_entity_name);
let mut decl = init.into_var_decl(VarDeclKind::Const, id.into());
let mut decl = init.into_var_decl(var_kind, id.into());

*module_item = if is_export {
ModuleDecl::ExportDecl(ExportDecl {
Expand Down

0 comments on commit 4aeefd0

Please sign in to comment.