Skip to content

Commit

Permalink
fix: Inherit comments from parent methods
Browse files Browse the repository at this point in the history
Resolves #1580
  • Loading branch information
Gerrit0 committed May 15, 2021
1 parent e9d5959 commit d5bb930
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/lib/converter/plugins/ImplementsPlugin.ts
Expand Up @@ -171,6 +171,7 @@ export class ImplementsPlugin extends ConverterComponent {
parentSig,
context.project
);
copyComment(childSig, parentSig);
}

child[key] = new ReferenceType(
Expand Down
6 changes: 3 additions & 3 deletions src/lib/converter/plugins/TypePlugin.ts
Expand Up @@ -98,11 +98,11 @@ export class TypePlugin extends ConverterComponent {
private onResolveEnd(context: Context) {
this.reflections.forEach((reflection) => {
if (reflection.implementedBy) {
reflection.implementedBy.sort((a: any, b: any) => {
if (a["name"] === b["name"]) {
reflection.implementedBy.sort((a, b) => {
if (a.name === b.name) {
return 0;
}
return a["name"] > b["name"] ? 1 : -1;
return a.name > b.name ? 1 : -1;
});
}

Expand Down
11 changes: 11 additions & 0 deletions src/test/converter2.test.ts
Expand Up @@ -194,6 +194,17 @@ const issueTests: Record<string, (project: ProjectReflection) => void> = {
"Symbol re-exported from ignored file is ignored."
);
},

gh1580(project) {
ok(
query(project, "B.prop").hasComment(),
"Overwritten property with no comment should be inherited"
);
ok(
query(project, "B.run").signatures?.[0]?.hasComment(),
"Overwritten method with no comment should be inherited"
);
},
};

describe("Converter2", () => {
Expand Down
18 changes: 18 additions & 0 deletions src/test/converter2/issues/gh1580.ts
@@ -0,0 +1,18 @@
export class A {
/** Prop docs */
prop!: string;

/** Run docs */
run(): void {
console.log("A");
}
}

export class B extends A {
prop!: "B";

run(): void {
super.run();
console.log("B");
}
}

0 comments on commit d5bb930

Please sign in to comment.