mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 18:43:44 +00:00
feat(minifier): fold typeof (() => {}) to 'function' (#8948)
This commit is contained in:
2 files changed
+4
-1
No files matched your search
@@ -401,7 +401,9 @@ pub trait ConstantEvaluation<'a>: MayHaveSideEffects {
|
||||
}
|
||||
"object"
|
||||
}
|
||||
Expression::FunctionExpression(_) => "function",
|
||||
Expression::FunctionExpression(_) | Expression::ArrowFunctionExpression(_) => {
|
||||
"function"
|
||||
}
|
||||
Expression::StringLiteral(_) => "string",
|
||||
Expression::NumericLiteral(_) => "number",
|
||||
Expression::BooleanLiteral(_) => "boolean",
|
||||
|
||||
@@ -1160,6 +1160,7 @@ mod test {
|
||||
fold("x = typeof {}", "x = \"object\"");
|
||||
test("var foo; NOOP(x = typeof { foo })", "var foo; NOOP(x = \"object\")");
|
||||
fold("x = typeof function() {}", "x = 'function'");
|
||||
fold("x = typeof (() => {})", "x = 'function'");
|
||||
fold_same("x = typeof foo"); // no sideeffect, but we don't know the result
|
||||
|
||||
fold_same("x = typeof[1,[foo()]]");
|
||||
|
||||
Reference in new issue
Block a user