Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/next' into fb/protect-the-top-of…
Browse files Browse the repository at this point in the history
…-file

# Conflicts:
#	src/utils/get-comment-registry.ts
#	tests/ImportCommentsPreserved/__snapshots__/ppsi.spec.ts.snap
#	tests/ImportCommentsPreserved/import-comments-trailing-specifier-comment-lost.ts
  • Loading branch information
IanVS committed May 15, 2023
2 parents 1e2ff94 + f7f0689 commit 99cceda
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/utils/get-comment-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,14 @@ export function attachCommentsToOutputNodes(
];

ownerNode = lastSpecifier;

// Start the comment on the line below the owner, to avoid gaps
if (
comment.loc?.start.line !== undefined &&
ownerNode.loc?.end.line
) {
comment.loc.start.line = ownerNode.loc?.end.line + 1;
}
}

if (!ownerNode) {
Expand Down
12 changes: 11 additions & 1 deletion tests/ImportCommentsPreserved/__snapshots__/ppsi.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ import {
/* @ts-expect-error*/
} from "c";
import {
b4,
a4,
// @ts-expect-error
} from "c2";
import {
b2,a2,
// @ts-expect-error
Expand All @@ -256,7 +262,6 @@ import {
import {
a1,
b1,
// @ts-expect-error
} from "a";
import {
Expand All @@ -265,5 +270,10 @@ import {
// @ts-expect-error
} from "b";
import { a3, b3 } from /* @ts-expect-error*/ "c";
import {
a4,
b4,
// @ts-expect-error
} from "c2";
`;
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import {
/* @ts-expect-error*/
} from "c";

import {
b4,
a4,
// @ts-expect-error
} from "c2";

import {
b2,a2,
// @ts-expect-error
Expand Down

0 comments on commit 99cceda

Please sign in to comment.