Skip to content

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

Closed
@xuhdev

Description

@xuhdev
Contributor

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

Activity

Gerrit0

Gerrit0 commented on Apr 6, 2024

@Gerrit0
Collaborator

Huh, that's strange... I must not have been paying enough attention.

added a commit that references this issue on Apr 7, 2024
b76d804
added a commit that references this issue on Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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

        Participants

        @xuhdev@Gerrit0

        Issue actions

          When a function parameter has type `NoInfer<T>`, `T` is removed from the generated doc · Issue #2539 · TypeStrong/typedoc