diff --git a/crates/biome_js_formatter/src/ts/auxiliary/type_constraint_clause.rs b/crates/biome_js_formatter/src/ts/auxiliary/type_constraint_clause.rs index bae47cf815ec..d5007d4b3e3b 100644 --- a/crates/biome_js_formatter/src/ts/auxiliary/type_constraint_clause.rs +++ b/crates/biome_js_formatter/src/ts/auxiliary/type_constraint_clause.rs @@ -12,6 +12,14 @@ impl FormatNodeRule for FormatTsTypeConstraintClause { let extends = extends_token.format(); let ty = ty.format(); - write![f, [extends, space(), ty]] + let group_id = f.group_id("constraint"); + write![ + f, + [ + extends, + group(&indent(&soft_line_break_or_space())).with_group_id(Some(group_id)), + indent_if_group_breaks(&ty, group_id) + ] + ] } } diff --git a/crates/biome_js_formatter/tests/specs/prettier/typescript/typeparams/line-breaking-after-extends.ts.snap b/crates/biome_js_formatter/tests/specs/prettier/typescript/typeparams/line-breaking-after-extends.ts.snap deleted file mode 100644 index 2e8c405bf2e8..000000000000 --- a/crates/biome_js_formatter/tests/specs/prettier/typescript/typeparams/line-breaking-after-extends.ts.snap +++ /dev/null @@ -1,86 +0,0 @@ ---- -source: crates/biome_formatter_test/src/snapshot_builder.rs -info: typescript/typeparams/line-breaking-after-extends.ts ---- - -# Input - -```ts -export type OuterType1< - LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerOtherType -> = { a: 1 }; - -export type OuterType2< - LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLongerLongerLongerOtherType -> = { a: 1 }; - -export type OuterType3< - LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLo.ngerLongerLongerOtherType -> = { a: 1 }; - -export type OuterType4< - LongerLongerLongerLongerInnerType extends - | LongerLongerLongerLongerLongerLo - | ngerLongerLongerOtherType -> = { a: 1 }; - -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Biome -@@ -1,16 +1,13 @@ - export type OuterType1< -- LongerLongerLongerLongerInnerType extends -- LongerLongerLongerLongerOtherType, -+ LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerOtherType, - > = { a: 1 }; - - export type OuterType2< -- LongerLongerLongerLongerInnerType extends -- LongerLongerLongerLongerLongerLongerLongerLongerOtherType, -+ LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLongerLongerLongerOtherType, - > = { a: 1 }; - - export type OuterType3< -- LongerLongerLongerLongerInnerType extends -- LongerLongerLongerLongerLongerLo.ngerLongerLongerOtherType, -+ LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLo.ngerLongerLongerOtherType, - > = { a: 1 }; - - export type OuterType4< -``` - -# Output - -```ts -export type OuterType1< - LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerOtherType, -> = { a: 1 }; - -export type OuterType2< - LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLongerLongerLongerOtherType, -> = { a: 1 }; - -export type OuterType3< - LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLo.ngerLongerLongerOtherType, -> = { a: 1 }; - -export type OuterType4< - LongerLongerLongerLongerInnerType extends - | LongerLongerLongerLongerLongerLo - | ngerLongerLongerOtherType, -> = { a: 1 }; -``` - -# Lines exceeding max width of 80 characters -``` - 2: LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerOtherType, - 6: LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLongerLongerLongerOtherType, - 10: LongerLongerLongerLongerInnerType extends LongerLongerLongerLongerLongerLo.ngerLongerLongerOtherType, -``` - -