fix(rome_js_analyzer):  precedence for `useOptionalChain`
MODIFY
crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/validCases.ts
crates/rome_js_analyze/tests/specs/nursery/useOptionalChain/validCases.ts
@@ -36,3 +36,5 @@ foo[12n] && foo[123n].baz;
foo[/\w+/] && foo[/ab+c/].baz;
((foo || {})()).bar;
+
+(new foo || {}).bar

MODIFY
crates/rome_js_syntax/src/expr_ext.rs
crates/rome_js_syntax/src/expr_ext.rs
@@ -562,10 +562,16 @@ impl JsAnyExpression {
JsAnyExpression::JsPostUpdateExpression(_)
| JsAnyExpression::JsPreUpdateExpression(_) => OperatorPrecedence::Update,
JsAnyExpression::JsCallExpression(_)
- | JsAnyExpression::JsNewExpression(_)
| JsAnyExpression::JsImportCallExpression(_)
| JsAnyExpression::JsSuperExpression(_) => OperatorPrecedence::LeftHandSide,
+ JsAnyExpression::JsNewExpression(expression) => {
+ if expression.arguments().is_none() {
+ OperatorPrecedence::NewWithoutArguments
+ } else {
+ OperatorPrecedence::LeftHandSide
+ }
+ }
JsAnyExpression::JsComputedMemberExpression(_)
| JsAnyExpression::JsStaticMemberExpression(_)
| JsAnyExpression::ImportMeta(_)

MODIFY
crates/rome_js_syntax/src/lib.rs
crates/rome_js_syntax/src/lib.rs
@@ -293,10 +293,12 @@ pub enum OperatorPrecedence {
Exponential = 15,
Unary = 16,
Update = 17,
- LeftHandSide = 18,
- Member = 19,
- Primary = 20,
- Group = 21,
+ // `new` without arguments list
+ NewWithoutArguments = 18,
+ LeftHandSide = 19,
+ Member = 20,
+ Primary = 21,
+ Group = 22,
}
impl OperatorPrecedence {

fix(rome_js_analyzer):  precedence for `useOptionalChain` (#3277)