Skip to content

Commit 9dcbd5d

Browse files
committed
Fix handling of cascadedModifierTags
Resolves #2802
1 parent f421460 commit 9dcbd5d

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ title: Changelog
44

55
## Unreleased
66

7+
### Bug Fixes
8+
9+
- Cascaded modifier tags will no longer be copied into type literals, #2802.
10+
711
## v0.27.3 (2024-12-04)
812

913
### Features

src/lib/converter/plugins/CommentPlugin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ export class CommentPlugin extends ConverterComponent {
453453

454454
// Any cascaded tags will show up twice, once on this and once on our signatures
455455
// This is completely redundant, so remove them from the wrapping function.
456-
if (sigs.length) {
456+
if (sigs.length && reflection.type?.type !== "reflection") {
457457
for (const mod of this.cascadedModifierTags) {
458458
reflection.comment.modifierTags.delete(mod);
459459
}
@@ -527,7 +527,9 @@ export class CommentPlugin extends ConverterComponent {
527527

528528
private cascadeModifiers(reflection: Reflection) {
529529
const parentComment = reflection.parent?.comment;
530-
if (!parentComment) return;
530+
if (!parentComment || reflection.kindOf(ReflectionKind.TypeLiteral)) {
531+
return;
532+
}
531533

532534
const childMods = reflection.comment?.modifierTags ?? new Set();
533535

src/test/converter2/issues/gh2802.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Docs
3+
* @alpha
4+
*/
5+
export type AlphaOk = number | string;
6+
7+
/**
8+
* Docs2
9+
* @alpha
10+
*/
11+
export type AlphaNoGo = (arg: number | string) => void;

src/test/issues.c2.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,4 +1942,19 @@ describe("Issue Tests", () => {
19421942
const type = query(project, "typeType");
19431943
equal(type.type?.toString(), "any");
19441944
});
1945+
1946+
it("#2802 preserves @alpha tags on signature types", () => {
1947+
const project = convert();
1948+
const alpha1 = query(project, "AlphaOk");
1949+
equal(Comment.combineDisplayParts(alpha1.comment?.summary), "Docs");
1950+
ok(alpha1.comment?.hasModifier("@alpha"));
1951+
1952+
const alpha2 = query(project, "AlphaNoGo");
1953+
equal(Comment.combineDisplayParts(alpha2.comment?.summary), "Docs2");
1954+
ok(alpha2.comment?.hasModifier("@alpha"));
1955+
1956+
// Modifiers should not have been cascaded
1957+
equal(alpha2.type?.type, "reflection");
1958+
equal(alpha2.type.declaration.comment, undefined);
1959+
});
19451960
});

0 commit comments

Comments
 (0)