Skip to content

Function returned by a class method copies the method's docs #2336

Closed
@mweidner037

Description

@mweidner037

Search terms

Anonymous function, function return, currying, inherit

Expected Behavior

When a class method returns an anonymous function, the anonymous function should either have no documentation (besides the method's @return annotation) or its own documentation.

Actual Behavior

When a class method returns an anonymous function, the anonymous function copies the method's docs.

Example code:

export class ClassVersion {
  /**
   * This is the outer function.
   *
   * @returns The inner function.
   */
  outer(): () => void {
    /** Docs for the inner function? */
    return () => {};
  }
}

Generated docs:
image

Steps to reproduce the bug

https://github.com/mweidner037/mwe-typedoc-returned-function

Environment

  • Typedoc version: 0.24.8
  • TypeScript version: 5.1.6
  • Node.js version: 16.13.1
  • OS: Ubuntu 22.04

More info

If the outer function is a standalone function instead of a class method, it behaves as I would expect:

/**
 * This is the outer function.
 *
 * @returns The inner function.
 */
export function outerAsFunction(): () => void {
  /** Docs for the inner function? */
  return () => {};
}

Generated docs:

image

Potentially related issue: #2283 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions