Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for function variables was not inferred #1523

Closed
JasonHK opened this issue Mar 2, 2021 · 4 comments
Closed

Documentation for function variables was not inferred #1523

JasonHK opened this issue Mar 2, 2021 · 4 comments
Labels
enhancement Improved functionality

Comments

@JasonHK
Copy link

JasonHK commented Mar 2, 2021

Search terms

const, function

Expected Behavior

Documentation for function variables should be inferred, i.e. the description, parameter descriptions etc. should be inherited.

interface Callable
{
    /**
     * Convert a number to a string.
     * 
     * @param payload A number.
     */
    (payload: number): string;

    /**
     * Convert a string to a number.
     * 
     * @param payload A string.
     */
    (payload: string): number;
}

export declare const callable: Callable;

Actual Behavior

2021-03-02_00004
2021-03-02_00003

Steps to reproduce the bug

Please refer to the code snippet above.

Environment

  • Typedoc version: 0.20.28
  • TypeScript version: 4.1.5
  • Node.js version: 14.15.5
  • OS: Kubuntu 20.04
@JasonHK JasonHK added the bug Functionality does not match expectation label Mar 2, 2021
@Gerrit0 Gerrit0 added enhancement Improved functionality and removed bug Functionality does not match expectation labels Mar 5, 2021
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 5, 2021

This is a really tricky one.

We could technically achieve this by relying on symbol.getDocumentationComment() in order to retrieve the comments... but unfortunately this directly conflicts with some other goals, since then comments on elements using declaration merging would show up in both places:

/** NS docs */
namespace Foo {}
/** Function docs */
function Foo() {}

I also wonder... what's the right solution in a case like this?

/** Does this get ignored? What it if includes important info like @hidden? */
export const callable: Callable = ...

I should really write down somewhere what TypeDoc currently does for comments so that it's easier to propose refinements to what it does...

@JasonHK
Copy link
Author

JasonHK commented Mar 6, 2021

This is a really tricky one.

We could technically achieve this by relying on symbol.getDocumentationComment() in order to retrieve the comments... but unfortunately this directly conflicts with some other goals, since then comments on elements using declaration merging would show up in both places:

/** NS docs */
namespace Foo {}
/** Function docs */
function Foo() {}

I also wonder... what's the right solution in a case like this?

/** Does this get ignored? What it if includes important info like @hidden? */
export const callable: Callable = ...

I should really write down somewhere what TypeDoc currently does for comments so that it's easier to propose refinements to what it does...

@Gerrit0 I think TypeDoc should at least inherit tags like @template, @param, @returns and @throws.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 6, 2021

Inheritance isn't the tricky part - we already do that for normal interface/class members. The tricky part is inherit from where? There is no implements clause here.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 26, 2022

image

In 0.23, TypeDoc tries to get docs from the signature itself, and therefore picks these up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improved functionality
Projects
None yet
Development

No branches or pull requests

2 participants