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

Callable variables use signature comment instead of variable comment #2042

Closed
VorontsovMaxim opened this issue Aug 27, 2022 · 2 comments
Closed
Labels
bug Functionality does not match expectation

Comments

@VorontsovMaxim
Copy link

Search terms

Callable variable object property

Expected Behavior

Written callable variable documentation should be included in the HTML output.

Actual Behavior

Written callable variable documentation is not included in the HTML output.

Steps to reproduce the bug

const obj = {
    /** function-docs */
    fn(x: unknown) {}
}

/**
 * exported-docs
 * @param x param-docs
 */
export const bug = obj.fn;

Only function-docs string is included in the HTML output, but not exported-docs string, neither as param-docs string.

But when you remove docs of function declaration exported-docs and param-docs appears in the HTML output.

const obj = {
    fn(x: unknown) {}
}

/**
 * exported-docs
 * @param x param-docs
 */
export const bug = obj.fn;

Here's repro PR: TypeStrong/typedoc-repros#20

Environment

  • Typedoc version: 0.23.11
  • TypeScript version: 4.8.2
  • Node.js version: 16.17.0
  • OS: macOS 12.4
@VorontsovMaxim VorontsovMaxim added the bug Functionality does not match expectation label Aug 27, 2022
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Aug 27, 2022

Hmm... this is going to be an annoying one to fix, because fixing this could easily break other usages where pulling the comment from the signature is expected.

@VorontsovMaxim
Copy link
Author

We haven't control over obj because it's autogenerated, but still want to document exported functions. So maybe there are some workarounds to get desired behaviour?

Also i just found one more similar problem with factory functions:

function factory() {
    /** function-docs */
    function fn() {};

    return fn;
}

/** exported-docs */
export const bug = factory();

@Gerrit0 Gerrit0 changed the title Callable variables not getting documentation Callable variables use signature comment instead of variable comment Sep 1, 2022
@Gerrit0 Gerrit0 closed this as completed in b8de8bf Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants