diff --git a/tests/format/typescript/comments/16121.ts b/tests/format/typescript/comments/16121.ts new file mode 100644 index 000000000..54c275371 --- /dev/null +++ b/tests/format/typescript/comments/16121.ts @@ -0,0 +1,38 @@ +export type IntersectionType = + & FirstPart + // Presence of comment makes this non-idempotent + & { + an: string, + object: string, + type: string, + } + + +export type IntersectionType = + & FirstPart + // Comment Line 1 + // Comment Line 2 + & { + an: string, + object: string, + type: string, + } + +export type IntersectionType = + | FirstPart + // Presence of comment is not a problem + | { + an: string; + object: string; + type: string; + }; + +export type IntersectionType = + | FirstPart + // Comment Line 1 + // Comment Line 2 + | { + an: string; + object: string; + type: string; + }; diff --git a/tests/format/typescript/comments/__snapshots__/format.test.js.snap b/tests/format/typescript/comments/__snapshots__/format.test.js.snap index fb6fbbe9c..a355bf9b9 100644 --- a/tests/format/typescript/comments/__snapshots__/format.test.js.snap +++ b/tests/format/typescript/comments/__snapshots__/format.test.js.snap @@ -250,6 +250,91 @@ class Foo { ================================================================================ `; +exports[`16121.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +export type IntersectionType = + & FirstPart + // Presence of comment makes this non-idempotent + & { + an: string, + object: string, + type: string, + } + + +export type IntersectionType = + & FirstPart + // Comment Line 1 + // Comment Line 2 + & { + an: string, + object: string, + type: string, + } + +export type IntersectionType = + | FirstPart + // Presence of comment is not a problem + | { + an: string; + object: string; + type: string; + }; + +export type IntersectionType = + | FirstPart + // Comment Line 1 + // Comment Line 2 + | { + an: string; + object: string; + type: string; + }; + +=====================================output===================================== +export type IntersectionType = FirstPart & + // Presence of comment makes this non-idempotent + { + an: string; + object: string; + type: string; + }; + +export type IntersectionType = FirstPart & + // Comment Line 1 + // Comment Line 2 + { + an: string; + object: string; + type: string; + }; + +export type IntersectionType = + | FirstPart + // Presence of comment is not a problem + | { + an: string; + object: string; + type: string; + }; + +export type IntersectionType = + | FirstPart + // Comment Line 1 + // Comment Line 2 + | { + an: string; + object: string; + type: string; + }; + +================================================================================ +`; + exports[`16207.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"]