@@ -392,7 +392,7 @@ impl<'a> AssignmentLike<'a, '_> {
392392 return AssignmentLikeLayout :: BreakAfterOperator ;
393393 }
394394
395- if self . should_break_left_hand_side ( ) {
395+ if self . should_break_left_hand_side ( left_may_break ) {
396396 return AssignmentLikeLayout :: BreakLeftHandSide ;
397397 }
398398
@@ -518,7 +518,7 @@ impl<'a> AssignmentLike<'a, '_> {
518518
519519 /// Particular function that checks if the left hand side of a [AssignmentLike] should
520520 /// be broken on multiple lines
521- fn should_break_left_hand_side ( & self ) -> bool {
521+ fn should_break_left_hand_side ( & self , left_may_break : bool ) -> bool {
522522 if self . is_complex_destructuring ( ) {
523523 return true ;
524524 }
@@ -534,9 +534,11 @@ impl<'a> AssignmentLike<'a, '_> {
534534 let type_annotation = declarator. id . type_annotation . as_ref ( ) ;
535535
536536 type_annotation. is_some_and ( |ann| is_complex_type_annotation ( ann) )
537- || ( self . get_right_expression ( ) . is_some_and ( |expr| {
538- matches ! ( expr. as_ref( ) , Expression :: ArrowFunctionExpression ( _) )
539- } ) && type_annotation. is_some_and ( |ann| is_annotation_breakable ( ann) ) )
537+ || ( left_may_break
538+ && declarator
539+ . init
540+ . as_ref ( )
541+ . is_some_and ( |expr| matches ! ( expr, Expression :: ArrowFunctionExpression ( _) ) ) )
540542 }
541543
542544 /// Checks if the current assignment is eligible for [AssignmentLikeLayout::BreakAfterOperator]
@@ -1009,15 +1011,6 @@ fn is_complex_type_arguments(type_arguments: &TSTypeParameterInstantiation) -> b
10091011 false
10101012}
10111013
1012- /// Checks if the annotation is breakable
1013- fn is_annotation_breakable ( annotation : & TSTypeAnnotation ) -> bool {
1014- matches ! (
1015- & annotation. type_annotation,
1016- TSType :: TSTypeReference ( reference_type)
1017- if reference_type. type_arguments. as_ref( ) . is_some_and( |type_args| !type_args. params. is_empty( ) )
1018- )
1019- }
1020-
10211014/// [Prettier applies]: <https://github.com/prettier/prettier/blob/fde0b49d7866e203ca748c306808a87b7c15548f/src/language-js/print/assignment.js#L278>
10221015pub fn is_complex_type_annotation ( annotation : & TSTypeAnnotation ) -> bool {
10231016 match & annotation. type_annotation {
0 commit comments