@@ -5426,7 +5426,7 @@ fn parse_union_or_intersection_type<'a>(node: UnionOrIntersectionType<'a>, conte
5426
5426
for ( i, type_node) in node. types . iter ( ) . enumerate ( ) {
5427
5427
let ( allow_inline_multi_line, allow_inline_single_line) = {
5428
5428
let is_last_value = i + 1 == types_count; // allow the last type to be single line
5429
- ( allows_inline_multi_line ( & type_node. into ( ) , types_count > 1 ) , is_last_value)
5429
+ ( allows_inline_multi_line ( & type_node. into ( ) , context , types_count > 1 ) , is_last_value)
5430
5430
} ;
5431
5431
let separator_token = context. token_finder . get_previous_token_if_operator ( & type_node. span ( ) , separator) ;
5432
5432
let start_info = Info :: new ( "startInfo" ) ;
@@ -6637,7 +6637,7 @@ fn parse_separated_values_with_result<'a>(opts: ParseSeparatedValuesParams<'a>,
6637
6637
} ;
6638
6638
let ( allow_inline_multi_line, allow_inline_single_line) = if let NodeOrSeparator :: Node ( value) = & value {
6639
6639
let is_last_value = node_index + 1 == nodes_count; // allow the last node to be single line
6640
- ( allows_inline_multi_line ( value, nodes_count > 1 ) , is_last_value)
6640
+ ( allows_inline_multi_line ( value, context , nodes_count > 1 ) , is_last_value)
6641
6641
} else {
6642
6642
( false , false )
6643
6643
} ;
@@ -8416,14 +8416,14 @@ fn is_arrow_function_with_expr_body(node: &Node) -> bool {
8416
8416
}
8417
8417
}
8418
8418
8419
- fn allows_inline_multi_line ( node : & Node , has_siblings : bool ) -> bool {
8419
+ fn allows_inline_multi_line ( node : & Node , context : & Context , has_siblings : bool ) -> bool {
8420
8420
return match node {
8421
- Node :: Param ( param) => allows_inline_multi_line ( & param. pat . into ( ) , has_siblings) ,
8421
+ Node :: Param ( param) => allows_inline_multi_line ( & param. pat . into ( ) , context , has_siblings) ,
8422
8422
Node :: TsAsExpr ( as_expr) => {
8423
- allows_inline_multi_line ( & as_expr. expr . into ( ) , has_siblings)
8423
+ allows_inline_multi_line ( & as_expr. expr . into ( ) , context , has_siblings)
8424
8424
&& match as_expr. type_ann {
8425
8425
TsType :: TsTypeRef ( _) | TsType :: TsKeywordType ( _) => true ,
8426
- _ => allows_inline_multi_line ( & as_expr. type_ann . into ( ) , has_siblings) ,
8426
+ _ => allows_inline_multi_line ( & as_expr. type_ann . into ( ) , context , has_siblings) ,
8427
8427
}
8428
8428
}
8429
8429
Node :: FnExpr ( _)
@@ -8435,16 +8435,19 @@ fn allows_inline_multi_line(node: &Node, has_siblings: bool) -> bool {
8435
8435
| Node :: TsTypeLit ( _)
8436
8436
| Node :: TsTupleType ( _)
8437
8437
| Node :: TsArrayType ( _) => true ,
8438
- Node :: ExprOrSpread ( node) => allows_inline_multi_line ( & node. expr . into ( ) , has_siblings) ,
8438
+ Node :: ExprOrSpread ( node) => allows_inline_multi_line ( & node. expr . into ( ) , context, has_siblings) ,
8439
+ Node :: ParenExpr ( node) => should_skip_paren_expr ( node, context) && allows_inline_multi_line ( & node. expr . into ( ) , context, has_siblings) ,
8439
8440
Node :: TaggedTpl ( _) | Node :: Tpl ( _) => !has_siblings,
8440
8441
Node :: CallExpr ( node) => !has_siblings && allow_inline_for_call_expr ( node) ,
8441
8442
Node :: BindingIdent ( node) => match & node. type_ann {
8442
- Some ( type_ann) => allows_inline_multi_line ( & type_ann. type_ann . into ( ) , has_siblings) ,
8443
+ Some ( type_ann) => allows_inline_multi_line ( & type_ann. type_ann . into ( ) , context , has_siblings) ,
8443
8444
None => false ,
8444
8445
} ,
8445
- Node :: AssignPat ( node) => allows_inline_multi_line ( & node. left . into ( ) , has_siblings) || allows_inline_multi_line ( & node. right . into ( ) , has_siblings) ,
8446
- Node :: TsTypeAnn ( type_ann) => allows_inline_multi_line ( & type_ann. type_ann . into ( ) , has_siblings) ,
8447
- Node :: TsTupleElement ( tuple_element) => allows_inline_multi_line ( & tuple_element. ty . into ( ) , has_siblings) ,
8446
+ Node :: AssignPat ( node) => {
8447
+ allows_inline_multi_line ( & node. left . into ( ) , context, has_siblings) || allows_inline_multi_line ( & node. right . into ( ) , context, has_siblings)
8448
+ }
8449
+ Node :: TsTypeAnn ( type_ann) => allows_inline_multi_line ( & type_ann. type_ann . into ( ) , context, has_siblings) ,
8450
+ Node :: TsTupleElement ( tuple_element) => allows_inline_multi_line ( & tuple_element. ty . into ( ) , context, has_siblings) ,
8448
8451
_ => false ,
8449
8452
} ;
8450
8453
0 commit comments