Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions bindings/binding_typescript_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ use swc_core::{
parser::{
parse_file_as_module, parse_file_as_program, parse_file_as_script, Syntax, TsSyntax,
},
transforms::base::{
fixer::fixer,
helpers::{inject_helpers, Helpers, HELPERS},
hygiene::hygiene,
resolver,
transforms::{
base::{
fixer::fixer,
helpers::{inject_helpers, Helpers, HELPERS},
hygiene::hygiene,
resolver,
},
typescript::strip_type,
},
visit::VisitMutWith,
},
Expand Down Expand Up @@ -52,9 +55,8 @@ pub struct Options {
#[serde(default)]
pub source_maps: bool,

#[serde(default)]
pub transform: swc_core::ecma::transforms::typescript::Config,

// #[serde(default)]
// pub transform: swc_core::ecma::transforms::typescript::Config,
#[serde(default)]
pub codegen: swc_core::ecma::codegen::Config,
}
Expand Down Expand Up @@ -148,10 +150,7 @@ fn operate(input: String, options: Options) -> Result<TransformOutput, Error> {

// Strip typescript types

program.visit_mut_with(&mut swc_core::ecma::transforms::typescript::typescript(
options.transform,
top_level_mark,
));
program.visit_mut_with(&mut strip_type());

// Apply external helpers

Expand Down
2 changes: 1 addition & 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,7 @@
#![allow(clippy::vec_box)]
#![allow(clippy::mutable_key_type)]

pub use self::typescript::*;
pub use self::{strip_type::*, typescript::*};
mod config;
mod macros;
mod strip_import_export;
Expand Down
4 changes: 4 additions & 0 deletions crates/swc_ecma_transforms_typescript/src/strip_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ use swc_ecma_visit::{VisitMut, VisitMutWith};

use crate::{type_to_none, unreachable_visit_mut_type};

pub fn strip_type() -> impl VisitMut {
StripType::default()
}

/// This Module will strip all types/generics/interface/declares
/// and type import/export
#[derive(Default)]
Expand Down