Skip to content

Commit

Permalink
Fix inheritDoc from signature to non-signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Mar 25, 2023
1 parent 1487f67 commit fb1658f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -47,6 +47,7 @@
### Bug Fixes

- TypeDoc will now ignore package.json files not containing a `name` field, #2190.
- Fixed `@inheritDoc` on signatures (functions, methods, constructors, getters, setters) being unable to inherit from a non-signature.

### Thanks!

Expand Down
3 changes: 2 additions & 1 deletion src/lib/converter/plugins/InheritDocPlugin.ts
Expand Up @@ -73,7 +73,8 @@ export class InheritDocPlugin extends ConverterComponent {
const index = reflection.parent
.getAllSignatures()
.indexOf(reflection);
sourceRefl = sourceRefl.getAllSignatures()[index];
sourceRefl =
sourceRefl.getAllSignatures()[index] || sourceRefl;
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/test/behaviorTests.ts
Expand Up @@ -365,6 +365,25 @@ export const behaviorTests: {
);
},

inheritDocSignature(project) {
const test1 = query(project, "SigRef.test1");
equal(test1.signatures?.length, 2);
equal(
Comment.combineDisplayParts(test1.signatures[0].comment?.summary),
"A"
);
equal(
Comment.combineDisplayParts(test1.signatures[1].comment?.summary),
"B"
);

const test2 = query(project, "SigRef.test2");
equal(
Comment.combineDisplayParts(test2.signatures?.[0].comment?.summary),
"C"
);
},

inheritDocWarnings(project, logger) {
const target1 = query(project, "target1");
equal(Comment.combineDisplayParts(target1.comment?.summary), "Source");
Expand Down
27 changes: 27 additions & 0 deletions src/test/converter2/behavior/inheritDocSignature.ts
@@ -0,0 +1,27 @@
// TS Discord March 24 2023 bug
// See https://discord.com/channels/508357248330760243/829307039447515176/1088969324770897931

export class SigRef {
/** A */
method(): void;
/** B */
method(x: string): string;
method(x?: string) {
return x;
}

/** C */
prop = 2;

/** {@inheritDoc method} */
test1(): void;

/** {@inheritDoc method} */
test1(x: string): string;
test1(x?: string) {
return x;
}

/** {@inheritDoc prop} */
test2() {}
}

0 comments on commit fb1658f

Please sign in to comment.