File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
oxc_minifier/src/peephole Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1169,6 +1169,11 @@ impl VariableDeclarationKind {
11691169 matches ! ( self , Self :: Const | Self :: Let | Self :: Using | Self :: AwaitUsing )
11701170 }
11711171
1172+ /// Returns `true` if declared with `using` (such as `using x` or `await using x`)
1173+ pub fn is_using ( self ) -> bool {
1174+ self == Self :: Using || self == Self :: AwaitUsing
1175+ }
1176+
11721177 /// Returns `true` if declared using `await using` (such as `await using x`)
11731178 pub fn is_await ( self ) -> bool {
11741179 self == Self :: AwaitUsing
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ impl<'a> PeepholeOptimizations {
1313 return false ;
1414 }
1515 if let BindingPatternKind :: BindingIdentifier ( ident) = & decl. id . kind {
16+ // Unsafe to remove `using`, unable to statically determine usage of [Symbol.dispose].
17+ if decl. kind . is_using ( ) {
18+ return false ;
19+ }
1620 if Self :: keep_top_level_var_in_script_mode ( ctx) {
1721 return false ;
1822 }
@@ -97,6 +101,8 @@ mod test {
97101 test_options ( "var x = foo" , "foo" , & options) ;
98102 test_same_options ( "var x; foo(x)" , & options) ;
99103 test_same_options ( "export var x" , & options) ;
104+ test_same_options ( "using x = foo" , & options) ;
105+ test_same_options ( "await using x = foo" , & options) ;
100106 }
101107
102108 #[ test]
You can’t perform that action at this time.
0 commit comments