Skip to content

Commit

Permalink
fix(es/fixer): Wrap class expressions in callee (#8928)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #8920
  • Loading branch information
kdy1 committed May 7, 2024
1 parent f4685ab commit 6b60bdb
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
64 changes: 64 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8920/input/.swcrc
@@ -0,0 +1,64 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es2022",
"loose": false,
"minify": {
"compress": {
"arguments": false,
"arrows": true,
"booleans": true,
"booleans_as_integers": false,
"collapse_vars": true,
"comparisons": true,
"computed_props": true,
"conditionals": true,
"dead_code": true,
"directives": true,
"drop_console": false,
"drop_debugger": true,
"evaluate": true,
"expression": false,
"hoist_funs": false,
"hoist_props": true,
"hoist_vars": false,
"if_return": true,
"join_vars": true,
"keep_classnames": false,
"keep_fargs": true,
"keep_fnames": false,
"keep_infinity": false,
"loops": true,
"negate_iife": true,
"properties": true,
"reduce_funcs": false,
"reduce_vars": false,
"side_effects": true,
"switches": true,
"typeofs": true,
"unsafe": false,
"unsafe_arrows": false,
"unsafe_comps": false,
"unsafe_Function": false,
"unsafe_math": false,
"unsafe_symbols": false,
"unsafe_methods": false,
"unsafe_proto": false,
"unsafe_regexp": false,
"unsafe_undefined": false,
"unused": true,
"const_to_let": true,
"pristine_globals": true
},
"mangle": false
}
},
"module": {
"type": "commonjs"
},
"minify": false,
"isModule": false
}
8 changes: 8 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8920/input/1.js
@@ -0,0 +1,8 @@
"use strict";
const k = (() => {
function f() {
class x { }
x();
}
return f;
})();
5 changes: 5 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8920/output/1.js
@@ -0,0 +1,5 @@
"use strict";
let k = function() {
(class {
})();
};
1 change: 1 addition & 0 deletions crates/swc_ecma_transforms_base/src/fixer.rs
Expand Up @@ -87,6 +87,7 @@ impl Fixer<'_> {
match e {
Expr::Lit(Lit::Num(..) | Lit::Str(..)) => (),
Expr::Cond(..)
| Expr::Class(..)
| Expr::Bin(..)
| Expr::Lit(..)
| Expr::Unary(..)
Expand Down

0 comments on commit 6b60bdb

Please sign in to comment.