Skip to content

Commit

Permalink
Improve generated JSDoc for @return tags
Browse files Browse the repository at this point in the history
  • Loading branch information
frandiox committed Aug 8, 2024
1 parent f4fe587 commit ab039ad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/cli/src/lib/transpile/morph/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ export function generateFunctionDocumentation(
const declaration = functionNode as FunctionDeclaration;
const jsDocs = declaration.getJsDocs()[0];

if (jsDocs?.getTags().length === 0) {
if (
jsDocs &&
!jsDocs.getTags().find((tag) => tag.getTagName() === 'return')
) {
const returnType = declaration.getReturnType().getText();
if (isAnnotableType(returnType)) {
const hasManuallySpecifiedReturnType = !!declaration
.getSignature()
.compilerSignature.getReturnType().aliasSymbol;

if (hasManuallySpecifiedReturnType) {
jsDocs.addTag({tagName: 'return', text: normalizeType(returnType)});
}
}
Expand Down

0 comments on commit ab039ad

Please sign in to comment.