Skip to content

When function return type is inferred, the displayed signature's return type is missing a type parameter #2079

@reify-thomas-smith

Description

@reify-thomas-smith

Search terms

Signature, return type, type parameter

Expected Behavior

Signature should be capitalize<T>(string: T): Capitalize<T>

Actual Behavior

Signature is capitalize<T>(string: T): Capitalize

Steps to reproduce the bug

/**
 * Capitalize the first letter of a string.
 */
export function capitalize<T extends string>(string: T) {
  return (
    string === '' ? '' : string[0].toUpperCase() + string.slice(1)
  ) as Capitalize<T>;
}

The bug does not occur if you add an explicit return type annotation.

Environment

  • Typedoc version: 0.23.17
  • TypeScript version: 4.7.4
  • Node.js version: 16.14.0
  • OS: macOS 12.6

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