Skip to content

Commit

Permalink
Turns on Typescript's only_remove_type_imports option in transformer (
Browse files Browse the repository at this point in the history
#40)

This option always causes idempotency test failures.
  • Loading branch information
Dunqing authored Sep 14, 2024
1 parent bb4f7e5 commit dc221cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/compressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ impl Case for CompressorRunner {

fn driver(&self) -> Driver {
// always compress js files
let mut transform = default_transformer_options();

// The compressor will remove unreachable code and the typescript plugin has a feature to remove unused imports.
// There is a conflict between these two features, so we need to disable the typescript plugin's feature.
transform.typescript.only_remove_type_imports = true;

Driver { transform: Some(transform), compress: true, ..Driver::default() }
Driver {
transform: Some(default_transformer_options()),
compress: true,
..Driver::default()
}
}
}
2 changes: 2 additions & 0 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub fn default_transformer_options() -> TransformOptions {
.unwrap();
// `object_rest_spread` is not ready
options.es2018.object_rest_spread = None;
// Enables `only_remove_type_imports` avoiding removing all unused imports
options.typescript.only_remove_type_imports = true;
options
}

Expand Down

0 comments on commit dc221cf

Please sign in to comment.