mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-06 17:34:25 +00:00
feat(ecmascript): support more simple expressions by ValueType::from (#8961)
This commit is contained in:
2 files changed
+13
-3
No files matched your search
@@ -71,7 +71,15 @@ impl<'a> From<&Expression<'a>> for ValueType {
|
||||
Expression::ObjectExpression(_)
|
||||
| Expression::ArrayExpression(_)
|
||||
| Expression::RegExpLiteral(_)
|
||||
| Expression::FunctionExpression(_) => Self::Object,
|
||||
| Expression::FunctionExpression(_)
|
||||
| Expression::ArrowFunctionExpression(_)
|
||||
| Expression::ClassExpression(_) => Self::Object,
|
||||
Expression::MetaProperty(meta_prop) => {
|
||||
match (meta_prop.meta.name.as_str(), meta_prop.property.name.as_str()) {
|
||||
("import", "meta") => Self::Object,
|
||||
_ => Self::Undetermined,
|
||||
}
|
||||
}
|
||||
Expression::Identifier(ident) => match ident.name.as_str() {
|
||||
"undefined" => Self::Undefined,
|
||||
"NaN" | "Infinity" => Self::Number,
|
||||
|
||||
@@ -30,8 +30,10 @@ fn literal_tests() {
|
||||
test("[0]", ValueType::Object);
|
||||
test("/a/", ValueType::Object);
|
||||
test("(function () {})", ValueType::Object);
|
||||
// test("(() => {})", ValueType::Object);
|
||||
// test("(class {})", ValueType::Object);
|
||||
test("(() => {})", ValueType::Object);
|
||||
test("(class {})", ValueType::Object);
|
||||
test("import.meta", ValueType::Object);
|
||||
// NOTE: new.target is undefined or object
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user