From 4918a06e320d6f052a906f748f46285d1de2728f Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Mon, 8 Jun 2026 19:42:27 +0800 Subject: [PATCH] Add regression test for object type (#19309) --- .../typescript/object-type/comments/11307.ts | 20 +++++++ .../__snapshots__/format.test.js.snap | 52 +++++++++++++++++++ .../object-type/comments/format.test.js | 1 + .../__snapshots__/format.test.js.snap | 0 .../object-multiline/format.test.js | 0 .../object-multiline/multiline.ts | 0 6 files changed, 73 insertions(+) create mode 100644 tests/format/typescript/object-type/comments/11307.ts create mode 100644 tests/format/typescript/object-type/comments/__snapshots__/format.test.js.snap create mode 100644 tests/format/typescript/object-type/comments/format.test.js rename tests/format/typescript/{ => object-type}/object-multiline/__snapshots__/format.test.js.snap (100%) rename tests/format/typescript/{ => object-type}/object-multiline/format.test.js (100%) rename tests/format/typescript/{ => object-type}/object-multiline/multiline.ts (100%) diff --git a/tests/format/typescript/object-type/comments/11307.ts b/tests/format/typescript/object-type/comments/11307.ts new file mode 100644 index 000000000..3e5b6f331 --- /dev/null +++ b/tests/format/typescript/object-type/comments/11307.ts @@ -0,0 +1,20 @@ +type T1 = (/** K */{ + K: number; +}) +type T2 = /** K */{ + K: number; +} + +const O1 = (/** K */{ + K: number, +}) +const O2 = /** K */{ + K: number, +} + +o = (/** K */{ + K: number, +}) +o = /** K */{ + K: number, +} diff --git a/tests/format/typescript/object-type/comments/__snapshots__/format.test.js.snap b/tests/format/typescript/object-type/comments/__snapshots__/format.test.js.snap new file mode 100644 index 000000000..87bc8e47d --- /dev/null +++ b/tests/format/typescript/object-type/comments/__snapshots__/format.test.js.snap @@ -0,0 +1,52 @@ +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing + +exports[`11307.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] + printWidth: 80 (default) | +=====================================input====================================== +type T1 = (/** K */{ + K: number; +}) +type T2 = /** K */{ + K: number; +} + +const O1 = (/** K */{ + K: number, +}) +const O2 = /** K */{ + K: number, +} + +o = (/** K */{ + K: number, +}) +o = /** K */{ + K: number, +} + +=====================================output===================================== +type T1 = /** K */ { + K: number; +}; +type T2 = /** K */ { + K: number; +}; + +const O1 = /** K */ { + K: number, +}; +const O2 = /** K */ { + K: number, +}; + +o = /** K */ { + K: number, +}; +o = /** K */ { + K: number, +}; + +================================================================================ +`; diff --git a/tests/format/typescript/object-type/comments/format.test.js b/tests/format/typescript/object-type/comments/format.test.js new file mode 100644 index 000000000..116dcbd78 --- /dev/null +++ b/tests/format/typescript/object-type/comments/format.test.js @@ -0,0 +1 @@ +runFormatTest(import.meta, ["typescript"]); diff --git a/tests/format/typescript/object-multiline/__snapshots__/format.test.js.snap b/tests/format/typescript/object-type/object-multiline/__snapshots__/format.test.js.snap similarity index 100% rename from tests/format/typescript/object-multiline/__snapshots__/format.test.js.snap rename to tests/format/typescript/object-type/object-multiline/__snapshots__/format.test.js.snap diff --git a/tests/format/typescript/object-multiline/format.test.js b/tests/format/typescript/object-type/object-multiline/format.test.js similarity index 100% rename from tests/format/typescript/object-multiline/format.test.js rename to tests/format/typescript/object-type/object-multiline/format.test.js diff --git a/tests/format/typescript/object-multiline/multiline.ts b/tests/format/typescript/object-type/object-multiline/multiline.ts similarity index 100% rename from tests/format/typescript/object-multiline/multiline.ts rename to tests/format/typescript/object-type/object-multiline/multiline.ts