Skip to content

Commit b53ca35

Browse files
authored
Merge pull request #826 from ocavue/ocavue-members-types
fix(core): remove some incorrect type assertions
2 parents 23e3320 + c399926 commit b53ca35

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

packages/typedoc-plugin-markdown/src/theme/context/partials/container.body.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from '@plugin/theme/lib/index.js';
77
import {
88
ContainerReflection,
9-
DeclarationReflection,
109
ReflectionGroup,
1110
ReflectionKind,
1211
} from 'typedoc';
@@ -54,7 +53,7 @@ export function body(
5453
} else {
5554
md.push(
5655
this.partials.members(
57-
group.children as DeclarationReflection[],
56+
group.children.filter(child => child.isDeclaration()),
5857
{
5958
headingLevel: options.headingLevel,
6059
},
@@ -83,9 +82,9 @@ export function body(
8382
children: model.children,
8483
} as ReflectionGroup),
8584
);
86-
} else {
85+
} else if (model.children) {
8786
md.push(
88-
this.partials.members(model.children as DeclarationReflection[], {
87+
this.partials.members(model.children, {
8988
headingLevel: options.headingLevel,
9089
}),
9190
);

packages/typedoc-plugin-markdown/src/theme/context/partials/container.categories.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
sortNoneSectionFirst,
66
} from '@plugin/theme/lib/index.js';
77
import {
8-
DeclarationReflection,
98
ReflectionCategory,
109
ReflectionKind,
1110
} from 'typedoc';
@@ -26,9 +25,9 @@ export function categories(
2625
}
2726
md.push(this.partials.groupIndex(category));
2827
} else {
29-
const categoryChildren = category.children?.filter(
28+
const categoryChildren = category.children.filter(
3029
(child) => child.kind !== ReflectionKind.Constructor,
31-
);
30+
).filter(child => child.isDeclaration());
3231
if (categoryChildren.length) {
3332
if (!isNoneSection(category)) {
3433
md.push(heading(options.headingLevel, category.title));
@@ -37,7 +36,7 @@ export function categories(
3736
md.push(this.helpers.getCommentParts(category.description));
3837
}
3938
md.push(
40-
this.partials.members(categoryChildren as DeclarationReflection[], {
39+
this.partials.members(categoryChildren, {
4140
headingLevel: isNoneSection(category)
4241
? options.headingLevel
4342
: options.headingLevel + 1,

packages/typedoc-plugin-markdown/src/theme/context/partials/container.groups.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from '@plugin/theme/lib/index.js';
77
import {
88
ContainerReflection,
9-
DeclarationReflection,
109
i18n,
1110
ProjectReflection,
1211
ReflectionKind,
@@ -97,7 +96,7 @@ export function groups(
9796
) {
9897
md.push(
9998
this.partials.propertiesTable(
100-
group.children as DeclarationReflection[],
99+
group.children.filter(child => child.isDeclaration()),
101100
{
102101
isEventProps,
103102
kind: options.kind,
@@ -107,13 +106,13 @@ export function groups(
107106
} else if (isEnumGroup && this.helpers.useTableFormat('enums')) {
108107
md.push(
109108
this.partials.enumMembersTable(
110-
group.children as DeclarationReflection[],
109+
group.children.filter(child => child.isDeclaration()),
111110
),
112111
);
113112
} else {
114113
if (group.children) {
115114
md.push(
116-
this.partials.members(group.children as DeclarationReflection[], {
115+
this.partials.members(group.children.filter(child => child.isDeclaration()), {
117116
headingLevel: isNoneSection(group)
118117
? options.headingLevel
119118
: options.headingLevel + 1,

packages/typedoc-plugin-markdown/src/theme/context/partials/container.members.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export function members(
1414
}
1515
return true;
1616
};
17-
const items = model?.filter((item) => !this.router.hasOwnDocument(item));
18-
items?.forEach((item, index) => {
17+
const items = model.filter((item) => !this.router.hasOwnDocument(item));
18+
items.forEach((item, index) => {
1919
md.push(
2020
this.partials.memberContainer(item, {
2121
headingLevel: options.headingLevel,

packages/typedoc-plugin-markdown/src/theme/context/partials/member.groupIndex.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ export function groupIndex(group: ReflectionGroup | ReflectionCategory) {
1919
if (this.options.getValue('indexFormat').toLowerCase().includes('table')) {
2020
return getGroupIndexTable(
2121
this,
22-
group.children as DeclarationReflection[] | DocumentReflection[],
22+
group.children,
2323
);
2424
}
2525
return getGroupIndexList(
2626
this,
27-
group.children as DeclarationReflection[] | DocumentReflection[],
27+
group.children,
2828
);
2929
}
3030

3131
export function getGroupIndexList(
3232
context: MarkdownThemeContext,
33-
children: DeclarationReflection[] | DocumentReflection[],
33+
children: (DeclarationReflection | DocumentReflection)[],
3434
) {
3535
const filteredChildren =
3636
children

0 commit comments

Comments
 (0)