Skip to content

Commit

Permalink
Minor code cleanup related to removing reflections
Browse files Browse the repository at this point in the history
Resolves #2448
  • Loading branch information
Gerrit0 committed Dec 28, 2023
1 parent 72726d3 commit 01be0e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/models/reflections/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export abstract class Reflection {
this.visit({
declaration(decl) {
if (
decl.signatures &&
decl.signatures?.length &&
decl.signatures.every(
(sig) => sig.comment?.getTag("@deprecated"),
)
Expand Down
16 changes: 16 additions & 0 deletions src/lib/models/reflections/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export class ProjectReflection extends ContainerReflection {
parent.children,
reflection as DeclarationReflection,
);
if (!parent.children?.length) {
delete parent.children;
}
} else if (property === TraverseProperty.GetSignature) {
delete parent.getSignature;
} else if (property === TraverseProperty.IndexSignature) {
Expand All @@ -144,20 +147,33 @@ export class ProjectReflection extends ContainerReflection {
(reflection.parent as SignatureReflection).parameters,
reflection as ParameterReflection,
);
if (
!(reflection.parent as SignatureReflection).parameters
?.length
) {
delete (reflection.parent as SignatureReflection)
.parameters;
}
} else if (property === TraverseProperty.SetSignature) {
delete parent.setSignature;
} else if (property === TraverseProperty.Signatures) {
removeIfPresent(
parent.signatures,
reflection as SignatureReflection,
);
if (!parent.signatures?.length) {
delete parent.signatures;
}
} else if (property === TraverseProperty.TypeLiteral) {
parent.type = new IntrinsicType("Object");
} else if (property === TraverseProperty.TypeParameter) {
removeIfPresent(
parent.typeParameters,
reflection as TypeParameterReflection,
);
if (!parent.typeParameters?.length) {
delete parent.typeParameters;
}
}

return false; // Stop iteration
Expand Down

0 comments on commit 01be0e1

Please sign in to comment.