Skip to content

Commit

Permalink
Fix comments on function types
Browse files Browse the repository at this point in the history
Resolves #2336
  • Loading branch information
Gerrit0 committed Dec 27, 2023
1 parent a636bd5 commit 7715f14
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Bug Fixes

- Methods which return function types no longer have duplicated comments, #2336.
- Fix crash when converting some complicated union/intersection types, #2451.
- Navigation triangle markers should no longer display on a separate line with some font settings, #2457.
- `@group` and `@category` organization is now applied later to allow inherited comments to create groups/categories, #2459.
Expand Down
6 changes: 1 addition & 5 deletions src/lib/converter/comments/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,7 @@ function declarationToCommentNode(node: ts.Declaration): ts.Node | undefined {
return node.parent.parent;
}

if (
[ts.SyntaxKind.NamespaceExport, ts.SyntaxKind.FunctionType].includes(
node.kind,
)
) {
if (ts.SyntaxKind.NamespaceExport === node.kind) {
return node.parent;
}

Expand Down
13 changes: 13 additions & 0 deletions src/test/converter2/issues/gh2336.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export class ClassVersion {
/**
* Outer
* @returns Returns Outer
*/
outer(): () => void {
/**
* Inner
* @returns Returns Inner
*/
return () => {};
}
}
15 changes: 15 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,21 @@ describe("Issue Tests", () => {
equal(tp.flags.isConst, true);
});

it("Handles comments with nested methods #2336", () => {
const project = convert();

const outer = querySig(project, "ClassVersion.outer");
equal(Comment.combineDisplayParts(outer.comment?.summary), "Outer");

equal(outer.type?.type, "reflection");
equal(
Comment.combineDisplayParts(
outer.type.declaration.signatures![0].comment?.summary,
),
"",
);
});

it("Supports nested paths with tsLinkResolution #2360", () => {
const project = convert();
const x = query(project, "x");
Expand Down

0 comments on commit 7715f14

Please sign in to comment.