diff --git a/packages/typedoc-plugin-markdown/src/theme/context/partials/container.body.ts b/packages/typedoc-plugin-markdown/src/theme/context/partials/container.body.ts index 1e46518e2..a101e1468 100644 --- a/packages/typedoc-plugin-markdown/src/theme/context/partials/container.body.ts +++ b/packages/typedoc-plugin-markdown/src/theme/context/partials/container.body.ts @@ -6,7 +6,6 @@ import { } from '@plugin/theme/lib/index.js'; import { ContainerReflection, - DeclarationReflection, ReflectionGroup, ReflectionKind, } from 'typedoc'; @@ -54,7 +53,7 @@ export function body( } else { md.push( this.partials.members( - group.children as DeclarationReflection[], + group.children.filter(child => child.isDeclaration()), { headingLevel: options.headingLevel, }, @@ -83,9 +82,9 @@ export function body( children: model.children, } as ReflectionGroup), ); - } else { + } else if (model.children) { md.push( - this.partials.members(model.children as DeclarationReflection[], { + this.partials.members(model.children, { headingLevel: options.headingLevel, }), ); diff --git a/packages/typedoc-plugin-markdown/src/theme/context/partials/container.categories.ts b/packages/typedoc-plugin-markdown/src/theme/context/partials/container.categories.ts index b8fa21293..6d28c00fe 100644 --- a/packages/typedoc-plugin-markdown/src/theme/context/partials/container.categories.ts +++ b/packages/typedoc-plugin-markdown/src/theme/context/partials/container.categories.ts @@ -5,7 +5,6 @@ import { sortNoneSectionFirst, } from '@plugin/theme/lib/index.js'; import { - DeclarationReflection, ReflectionCategory, ReflectionKind, } from 'typedoc'; @@ -26,9 +25,9 @@ export function categories( } md.push(this.partials.groupIndex(category)); } else { - const categoryChildren = category.children?.filter( + const categoryChildren = category.children.filter( (child) => child.kind !== ReflectionKind.Constructor, - ); + ).filter(child => child.isDeclaration()); if (categoryChildren.length) { if (!isNoneSection(category)) { md.push(heading(options.headingLevel, category.title)); @@ -37,7 +36,7 @@ export function categories( md.push(this.helpers.getCommentParts(category.description)); } md.push( - this.partials.members(categoryChildren as DeclarationReflection[], { + this.partials.members(categoryChildren, { headingLevel: isNoneSection(category) ? options.headingLevel : options.headingLevel + 1, diff --git a/packages/typedoc-plugin-markdown/src/theme/context/partials/container.groups.ts b/packages/typedoc-plugin-markdown/src/theme/context/partials/container.groups.ts index c69e4e8b8..29522f165 100644 --- a/packages/typedoc-plugin-markdown/src/theme/context/partials/container.groups.ts +++ b/packages/typedoc-plugin-markdown/src/theme/context/partials/container.groups.ts @@ -6,7 +6,6 @@ import { } from '@plugin/theme/lib/index.js'; import { ContainerReflection, - DeclarationReflection, i18n, ProjectReflection, ReflectionKind, @@ -97,7 +96,7 @@ export function groups( ) { md.push( this.partials.propertiesTable( - group.children as DeclarationReflection[], + group.children.filter(child => child.isDeclaration()), { isEventProps, kind: options.kind, @@ -107,13 +106,13 @@ export function groups( } else if (isEnumGroup && this.helpers.useTableFormat('enums')) { md.push( this.partials.enumMembersTable( - group.children as DeclarationReflection[], + group.children.filter(child => child.isDeclaration()), ), ); } else { if (group.children) { md.push( - this.partials.members(group.children as DeclarationReflection[], { + this.partials.members(group.children.filter(child => child.isDeclaration()), { headingLevel: isNoneSection(group) ? options.headingLevel : options.headingLevel + 1, diff --git a/packages/typedoc-plugin-markdown/src/theme/context/partials/container.members.ts b/packages/typedoc-plugin-markdown/src/theme/context/partials/container.members.ts index f372940f2..37489d667 100644 --- a/packages/typedoc-plugin-markdown/src/theme/context/partials/container.members.ts +++ b/packages/typedoc-plugin-markdown/src/theme/context/partials/container.members.ts @@ -14,8 +14,8 @@ export function members( } return true; }; - const items = model?.filter((item) => !this.router.hasOwnDocument(item)); - items?.forEach((item, index) => { + const items = model.filter((item) => !this.router.hasOwnDocument(item)); + items.forEach((item, index) => { md.push( this.partials.memberContainer(item, { headingLevel: options.headingLevel, diff --git a/packages/typedoc-plugin-markdown/src/theme/context/partials/member.groupIndex.ts b/packages/typedoc-plugin-markdown/src/theme/context/partials/member.groupIndex.ts index 08d429661..5c3d5b5b5 100644 --- a/packages/typedoc-plugin-markdown/src/theme/context/partials/member.groupIndex.ts +++ b/packages/typedoc-plugin-markdown/src/theme/context/partials/member.groupIndex.ts @@ -19,18 +19,18 @@ export function groupIndex(group: ReflectionGroup | ReflectionCategory) { if (this.options.getValue('indexFormat').toLowerCase().includes('table')) { return getGroupIndexTable( this, - group.children as DeclarationReflection[] | DocumentReflection[], + group.children, ); } return getGroupIndexList( this, - group.children as DeclarationReflection[] | DocumentReflection[], + group.children, ); } export function getGroupIndexList( context: MarkdownThemeContext, - children: DeclarationReflection[] | DocumentReflection[], + children: (DeclarationReflection | DocumentReflection)[], ) { const filteredChildren = children