Skip to content

Commit bc6130a

Browse files
committed
Fix removeReflection skipping every other parameter
1 parent 98841f5 commit bc6130a

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Fixed `--validation.notDocumented` warnings for functions/methods, #1895.
77
- Search results will no longer include random items when the search bar is empty, #1881.
88
- Comments on overloaded constructors will now be detected in the same way that overloaded functions/methods are.
9+
- Fixed `removeReflection` not completely removing reflections from the project.
910

1011
### Thanks!
1112

src/lib/models/reflections/container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class ContainerReflection extends Reflection {
3939
* @param callback The callback function that should be applied for each child reflection.
4040
*/
4141
override traverse(callback: TraverseCallback) {
42-
for (const child of this.children ?? []) {
42+
for (const child of this.children?.slice() || []) {
4343
if (callback(child, TraverseProperty.Children) === false) {
4444
return;
4545
}

src/lib/models/reflections/declaration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class DeclarationReflection extends ContainerReflection {
170170
* @param callback The callback function that should be applied for each child reflection.
171171
*/
172172
override traverse(callback: TraverseCallback) {
173-
for (const parameter of this.typeParameters ?? []) {
173+
for (const parameter of this.typeParameters?.slice() || []) {
174174
if (callback(parameter, TraverseProperty.TypeParameter) === false) {
175175
return;
176176
}
@@ -187,7 +187,7 @@ export class DeclarationReflection extends ContainerReflection {
187187
}
188188
}
189189

190-
for (const signature of this.signatures ?? []) {
190+
for (const signature of this.signatures?.slice() || []) {
191191
if (callback(signature, TraverseProperty.Signatures) === false) {
192192
return;
193193
}

src/lib/models/reflections/signature.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ export class SignatureReflection extends Reflection {
7373
}
7474
}
7575

76-
for (const parameter of this.typeParameters ?? []) {
76+
for (const parameter of this.typeParameters?.slice() || []) {
7777
if (callback(parameter, TraverseProperty.TypeParameter) === false) {
7878
return;
7979
}
8080
}
8181

82-
for (const parameter of this.parameters ?? []) {
82+
for (const parameter of this.parameters?.slice() || []) {
8383
if (callback(parameter, TraverseProperty.Parameters) === false) {
8484
return;
8585
}

src/test/behaviorTests.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,13 @@ export const behaviorTests: Record<
7070

7171
equal(foo.comment, undefined);
7272
},
73+
74+
removeReflection(project) {
75+
const foo = query(project, "foo");
76+
project.removeReflection(foo);
77+
equal(
78+
Object.values(project.reflections).map((r) => r.name),
79+
["typedoc"]
80+
);
81+
},
7382
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function foo(first: string, second: string, third: string) {
2+
first;
3+
second;
4+
third;
5+
}

0 commit comments

Comments
 (0)