Skip to content

Type parameters of generic javascript classes are stripped of their types #2929

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

Closed
stwlam opened this issue Apr 6, 2025 · 1 comment
Closed
Labels
js This issue relates to better TS-in-JS support
Milestone

Comments

@stwlam
Copy link

stwlam commented Apr 6, 2025

Search terms

template, typeParam, class

Expected Behavior

Types of javascript class type parameters, if present, are rendered.

Actual Behavior

Types of javascript class type parameters, when present, are not rendered.

Steps to reproduce the bug

Add the following to the example/classes directory (also export from index and turn on allowJs:

/**
 * @template {number} T
 */
export class NumberManager {
     /**
      *
      * @param {T[]} nums
      */
    constructor(nums) {
        this.nums = nums;
    }

    /** @type {T[]} */
    nums;
}

Build the examples and note the lack of the number type for T in the class type parameter but not the constructor's:

Environment

  • Typedoc version: 0.28.1
  • TypeScript version: 5.6.3
  • Node.js version: 22.14.0
  • OS: Ubuntu 22.04.5
@Gerrit0 Gerrit0 added the js This issue relates to better TS-in-JS support label Apr 7, 2025
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 7, 2025

Oh TS-JSDoc, why do you have to be so horrible... this happens because the AST for that class does not include type parameter constraints on the type parameters when getting them for the class, so typedoc is going to have to find it in some other completely inconvenient location...

@Gerrit0 Gerrit0 added this to the v0.28.2 milestone Apr 7, 2025
@Gerrit0 Gerrit0 closed this as completed in 031f7a4 Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js This issue relates to better TS-in-JS support
Projects
None yet
Development

No branches or pull requests

2 participants