diff --git a/CHANGELOG.md b/CHANGELOG.md index cc4f9e87f..ba015d633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed flash when navigating to a second page when OS theme does not match selected theme, #1709. - Fixed improper quoting of `as const` style enums, #1727. +- Fixed handling of `@typeParam` on type aliases, #1733. ### Thanks! diff --git a/src/lib/converter/symbols.ts b/src/lib/converter/symbols.ts index 8b200837a..fd6b0beec 100644 --- a/src/lib/converter/symbols.ts +++ b/src/lib/converter/symbols.ts @@ -302,11 +302,14 @@ function convertTypeAlias( declaration.type ); + context.finalizeDeclarationReflection(reflection, symbol, exportSymbol); + + // Do this after finalization so that the CommentPlugin can get @typeParam tags + // from the parent comment. Ugly, but works for now. Should be cleaned up with TSDoc + // support. reflection.typeParameters = declaration.typeParameters?.map((param) => createTypeParamReflection(param, context.withScope(reflection)) ); - - context.finalizeDeclarationReflection(reflection, symbol, exportSymbol); } else if ( ts.isJSDocTypedefTag(declaration) || ts.isJSDocEnumTag(declaration) diff --git a/src/lib/models/ReflectionCategory.ts b/src/lib/models/ReflectionCategory.ts index 80d3640a2..4ded91fe9 100644 --- a/src/lib/models/ReflectionCategory.ts +++ b/src/lib/models/ReflectionCategory.ts @@ -18,14 +18,6 @@ export class ReflectionCategory { */ children: Reflection[] = []; - /** - * Do all children of this category have a separate document? - * - * A bound representation of the ´ReflectionCategory.getAllChildrenHaveOwnDocument´ - * that can be used within templates. - */ - allChildrenHaveOwnDocument: Function; - /** * Create a new ReflectionCategory instance. * @@ -33,20 +25,12 @@ export class ReflectionCategory { */ constructor(title: string) { this.title = title; - - this.allChildrenHaveOwnDocument = () => - this.getAllChildrenHaveOwnDocument(); } /** * Do all children of this category have a separate document? */ - private getAllChildrenHaveOwnDocument(): boolean { - let onlyOwnDocuments = true; - this.children.forEach((child) => { - onlyOwnDocuments = onlyOwnDocuments && !!child.hasOwnDocument; - }); - - return onlyOwnDocuments; + allChildrenHaveOwnDocument(): boolean { + return this.children.every((child) => child.hasOwnDocument); } } diff --git a/src/lib/models/ReflectionGroup.ts b/src/lib/models/ReflectionGroup.ts index 7a49f6ef6..52388295b 100644 --- a/src/lib/models/ReflectionGroup.ts +++ b/src/lib/models/ReflectionGroup.ts @@ -30,14 +30,6 @@ export class ReflectionGroup { */ cssClasses?: string; - /** - * Do all children of this group have a separate document? - * - * A bound representation of the ´ReflectionGroup.getAllChildrenHaveOwnDocument´ - * that can be used within templates. - */ - allChildrenHaveOwnDocument = () => this.getAllChildrenHaveOwnDocument(); - /** * Are all children inherited members? */ @@ -77,7 +69,7 @@ export class ReflectionGroup { /** * Do all children of this group have a separate document? */ - private getAllChildrenHaveOwnDocument(): boolean { + allChildrenHaveOwnDocument(): boolean { return this.children.every((child) => child.hasOwnDocument); } } diff --git a/src/test/converter2/issues/gh1733.ts b/src/test/converter2/issues/gh1733.ts new file mode 100644 index 000000000..48e341956 --- /dev/null +++ b/src/test/converter2/issues/gh1733.ts @@ -0,0 +1,9 @@ +/** + * @typeParam T T docs + */ +export type Foo = T; + +/** + * @typeParam T T docs + */ +export class Bar {} diff --git a/src/test/issueTests.ts b/src/test/issueTests.ts index 5e7bc65cc..c09efa407 100644 --- a/src/test/issueTests.ts +++ b/src/test/issueTests.ts @@ -235,4 +235,11 @@ export const issueTests: { ok(alias.type instanceof QueryType); equal(alias.type.queryType.name, "m.SomeClass.someProp"); }, + + gh1733(project) { + const alias = query(project, "Foo"); + equal(alias.typeParameters?.[0].comment?.shortText.trim(), "T docs"); + const cls = query(project, "Bar"); + equal(cls.typeParameters?.[0].comment?.shortText.trim(), "T docs"); + }, };