Skip to content

Commit

Permalink
chore: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Jul 21, 2023
1 parent 4aeefd0 commit b75ecb7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
10 changes: 0 additions & 10 deletions crates/swc_ecma_transforms_typescript/src/collect.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/swc_ecma_transforms_typescript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(clippy::vec_box)]

pub use self::strip::*;
mod collect;
mod import_export_assign;
mod inline_enum;
mod macros;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl VisitMut for StripImportExport {
n.visit_with(&mut usage_info);
n.visit_with(&mut declare_info);

let mut strip_ts_import_equals = StripTsImportEquals::default();
let mut strip_ts_import_equals = StripTsImportEquals;

n.retain_mut(|module_item| match module_item {
ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
Expand Down Expand Up @@ -306,7 +306,7 @@ impl VisitMut for StripImportExport {
}

fn visit_mut_script(&mut self, n: &mut Script) {
let mut visitor = StripTsImportEquals::default();
let mut visitor = StripTsImportEquals;
for stmt in n.body.iter_mut() {
if let Stmt::Decl(Decl::TsModule(..)) = stmt {
stmt.visit_mut_with(&mut visitor);
Expand Down
3 changes: 3 additions & 0 deletions crates/swc_ecma_transforms_typescript/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,20 @@ pub(crate) struct Transform {

unresolved_mark: Mark,
import_export_assign_config: TsImportExportAssignConfig,
verbatim_module_syntax: bool,

namespace_id: Option<Id>,
}

pub fn transform(
unresolved_mark: Mark,
import_export_assign_config: TsImportExportAssignConfig,
verbatim_module_syntax: bool,
) -> impl Fold + VisitMut {
as_folder(Transform {
unresolved_mark,
import_export_assign_config,
verbatim_module_syntax,
..Default::default()
})
}
Expand Down
11 changes: 4 additions & 7 deletions crates/swc_ecma_transforms_typescript/src/typescript.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use serde::{Deserialize, Serialize};
use swc_common::Mark;
use swc_ecma_ast::*;
use swc_ecma_visit::{as_folder, Fold, VisitMut, VisitMutWith, VisitWith};
use swc_ecma_visit::{as_folder, Fold, VisitMut, VisitMutWith};

use crate::{
collect::Collect, strip_import_export::StripImportExport, strip_type::StripType,
transform::transform, TsImportExportAssignConfig,
strip_import_export::StripImportExport, strip_type::StripType, transform::transform,
TsImportExportAssignConfig,
};

#[derive(Debug, Default, Serialize, Deserialize)]
Expand Down Expand Up @@ -56,13 +56,10 @@ impl VisitMut for TypeScript {

n.visit_mut_with(&mut StripType::default());

if !self.config.verbatim_module_syntax {
n.visit_with(&mut Collect);
}

n.visit_mut_with(&mut transform(
self.unresolved_mark,
self.config.import_export_assign_config,
self.config.verbatim_module_syntax,
));
}
}

0 comments on commit b75ecb7

Please sign in to comment.