mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(minifier): remove unused arrow function expressions (#8262)
This commit is contained in:
parent
e446c15619
commit
04ec38dc47
1 changed files with 11 additions and 0 deletions
|
|
@ -310,6 +310,7 @@ impl<'a, 'b> PeepholeRemoveDeadCode {
|
|||
Expression::FunctionExpression(function_expr) if function_expr.id.is_none() => {
|
||||
Some(ctx.ast.statement_empty(SPAN))
|
||||
}
|
||||
Expression::ArrowFunctionExpression(_) => Some(ctx.ast.statement_empty(SPAN)),
|
||||
// `typeof x` -> ``
|
||||
Expression::UnaryExpression(unary_expr)
|
||||
if unary_expr.operator.is_typeof()
|
||||
|
|
@ -583,4 +584,14 @@ mod test {
|
|||
fold_same("delete x.y");
|
||||
fold_same("delete x.y.z()");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fold_function() {
|
||||
fold("() => {}", "");
|
||||
fold_same("var k = () => {}");
|
||||
fold_same("var k = function () {}");
|
||||
// TODO: fold the following...
|
||||
fold_same("(() => {})()");
|
||||
fold_same("(function () {})()");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue