Skip to content

When a function parameter has type NoInfer<T>, T is removed from the generated doc #2539

Closed
@xuhdev

Description

@xuhdev

Search terms

NoInfer, TypeScript 5.4

Expected Behavior

When NoInfer<T> is used in a function parameter, T is retained in the document output of this function parameter. This is because T is still informational, indicating that the function parameter has type T -- it's just that T can't be inferred from this function parameter.

Actual Behavior

T is removed from this function parameter in the doc.

Steps to reproduce the bug

(The corresponding test does not check for C:

equal(sig.parameters[1].type?.toString(), "NoInfer");
)

  1. Download the test file: https://github.com/TypeStrong/typedoc/blob/3398e98dce4de5d7c5a53f1f6c66e1af8aa28cc9/src/test/converter2/behavior/noInfer.ts
export function createStreetLight<C extends string>(
    colors: C[],
    defaultColor?: NoInfer<C>,
) {}

// @ts-expect-error
createStreetLight(["red", "yellow", "green"], "blue");
  1. npm install --save-dev typedoc
  2. npx typedoc NoInfer.ts
  3. Observe that C is gone from the defaultColor parameter description

Environment

  • Typedoc version: 0.25.12
  • TypeScript version: 5.4.3
  • Node.js version: 20.12.1
  • OS: Debian

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