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
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<'a> Expression<'a> {
/// Note that this includes [`Class`]s.
/// <https://262.ecma-international.org/15.0/#sec-isanonymousfunctiondefinition>
pub fn is_anonymous_function_definition(&self) -> bool {
match self {
match self.without_parentheses() {
Self::ArrowFunctionExpression(_) => true,
Self::FunctionExpression(func) => func.name().is_none(),
Self::ClassExpression(class) => class.name().is_none(),
Expand Down
5 changes: 4 additions & 1 deletion crates/oxc_mangler/src/keep_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl<'a, 'b: 'a> NameSymbolCollector<'a, 'b> {
return true;
}

let is_class = matches!(expr, Expression::ClassExpression(_));
let is_class = matches!(expr.without_parentheses(), Expression::ClassExpression(_));
(self.options.class && is_class) || (self.options.function && !is_class)
}
}
Expand Down Expand Up @@ -291,8 +291,11 @@ mod test {
#[test]
fn test_simple_declare_init() {
assert_eq!(collect(function_only(), "var foo = function() {}"), data("foo"));
assert_eq!(collect(function_only(), "var foo = (function() {})"), data("foo"));
assert_eq!(collect(function_only(), "var foo = () => {}"), data("foo"));
assert_eq!(collect(function_only(), "var foo = (() => {})"), data("foo"));
assert_eq!(collect(class_only(), "var Foo = class {}"), data("Foo"));
assert_eq!(collect(class_only(), "var Foo = (class {})"), data("Foo"));
}

#[test]
Expand Down
Loading