From 8d5b07edc9ba6fbc015854bb10c38d22474dc958 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 23 Dec 2022 11:51:33 +0100 Subject: [PATCH] fix(rome_js_formatter): Union in mapped type ## Summary Fixes #4074 --- .../rome_js_formatter/src/ts/types/union_type.rs | 1 + .../tests/specs/ts/type/union_type.ts | 4 ++-- .../tests/specs/ts/type/union_type.ts.snap | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/rome_js_formatter/src/ts/types/union_type.rs b/crates/rome_js_formatter/src/ts/types/union_type.rs index 9a8d24413f6..7c2ea9c7166 100644 --- a/crates/rome_js_formatter/src/ts/types/union_type.rs +++ b/crates/rome_js_formatter/src/ts/types/union_type.rs @@ -53,6 +53,7 @@ impl FormatNodeRule for FormatTsUnionType { | JsSyntaxKind::TS_TUPLE_TYPE_ELEMENT_LIST | JsSyntaxKind::TS_TYPE_ASSERTION_ASSIGNMENT | JsSyntaxKind::TS_TYPE_ARGUMENT_LIST + | JsSyntaxKind::TS_MAPPED_TYPE ) ) } diff --git a/crates/rome_js_formatter/tests/specs/ts/type/union_type.ts b/crates/rome_js_formatter/tests/specs/ts/type/union_type.ts index b71ab330414..9cf99369a89 100644 --- a/crates/rome_js_formatter/tests/specs/ts/type/union_type.ts +++ b/crates/rome_js_formatter/tests/specs/ts/type/union_type.ts @@ -12,7 +12,7 @@ type Comments = trailing type */ type A = [ - /*leading comment with new line*/ + /*leading comment with new line*/ A | B, ]; @@ -243,4 +243,4 @@ type GetChatsSagaEffects = type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla = | Fooo1000 | Baz2000 -| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong; \ No newline at end of file +| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong; diff --git a/crates/rome_js_formatter/tests/specs/ts/type/union_type.ts.snap b/crates/rome_js_formatter/tests/specs/ts/type/union_type.ts.snap index f16699b20f3..e230d2d1210 100644 --- a/crates/rome_js_formatter/tests/specs/ts/type/union_type.ts.snap +++ b/crates/rome_js_formatter/tests/specs/ts/type/union_type.ts.snap @@ -1,7 +1,6 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: - test_file: ts/type/union_type.ts +info: "ts\\type\\union_type.ts" --- # Input @@ -21,7 +20,7 @@ type Comments = trailing type */ type A = [ - /*leading comment with new line*/ + /*leading comment with new line*/ A | B, ]; @@ -253,6 +252,7 @@ type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla = | Fooo1000 | Baz2000 | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong; + ``` @@ -377,10 +377,10 @@ const fooo: SomeThingWithShortMappedType<{ const fooo: SomeThingWithLongMappedType<{ [P in - | AAAAAAAAAAAAAAAAA - | BBBBBBBBBBBB - | CCCCCCCCCCCCCCCCCCCCC - | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD]: number; + | AAAAAAAAAAAAAAAAA + | BBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD]: number; }> = {}; export type A =