diff --git a/src/utils/get-comment-registry.ts b/src/utils/get-comment-registry.ts index 37fdfb6..55cd6c9 100644 --- a/src/utils/get-comment-registry.ts +++ b/src/utils/get-comment-registry.ts @@ -406,7 +406,7 @@ export function attachCommentsToOutputNodes( * This works since late 2022, Babel uses `loc` (if-present) to hint how to render for some cases. */ const patchNewFirstImportLocationOnlyOnce = () => { - if (!hasPatchedNewFirstImportLocation) { + if (hasPatchedNewFirstImportLocation) { return; } diff --git a/tests/ImportCommentsPreserved/__snapshots__/ppsi.spec.ts.snap b/tests/ImportCommentsPreserved/__snapshots__/ppsi.spec.ts.snap index d248e4c..2ac7fb3 100644 --- a/tests/ImportCommentsPreserved/__snapshots__/ppsi.spec.ts.snap +++ b/tests/ImportCommentsPreserved/__snapshots__/ppsi.spec.ts.snap @@ -102,6 +102,21 @@ import { useState } from "react"; `; +exports[`import-comments-no-top-gap.ts - typescript-verify > import-comments-no-top-gap.ts 1`] = ` +/** + * @prettier + */ +import { requireValue } from './utils/require/requireValue'; +import { fooValue } from './foo'; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +/** + * @prettier + */ +import { fooValue } from "./foo"; +import { requireValue } from "./utils/require/requireValue"; + +`; + exports[`import-comments-outer-comments-block-comments.ts - typescript-verify > import-comments-outer-comments-block-comments.ts 1`] = ` // Loose leading comment before imports (should not be dragged down with B) diff --git a/tests/ImportCommentsPreserved/import-comments-no-top-gap.ts b/tests/ImportCommentsPreserved/import-comments-no-top-gap.ts new file mode 100644 index 0000000..b246749 --- /dev/null +++ b/tests/ImportCommentsPreserved/import-comments-no-top-gap.ts @@ -0,0 +1,5 @@ +/** + * @prettier + */ +import { requireValue } from './utils/require/requireValue'; +import { fooValue } from './foo';