Skip to content

Failing to resolve multiple JSDOC @template tags #46618

@JacobNorlin

Description

@JacobNorlin

Bug Report

Using generics on both an ES5 class and methods results in incomplete type resolution.

🔎 Search Terms

jsdoc, template, generic

🕗 Version & Regression Information

Typescript 4.4.4, 4.5.0-beta

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about JSDoc/generics/templates

⏯ Playground Link

Playground link with relevant code

💻 Code

/**
 * @template {string} T
 * @param {T} t
 */
function Cls(t) {
    this.t = t;
}

/**
 * @template {string} V
 * @param {T} t 
 * @param {V} v 
 */
Cls.prototype.func1 = function (t, v) {
};


Cls.prototype.func2 =
    /**
     * @template {string} V
     * @param {T} t 
     * @param {V} v 
     */
    function (t, v) {
    };

var c = new Cls('a');
c.func1('a', 'b'); //Can't resolve V generic
c.func2('a', 'b'); //Can't T generic in argument

🙁 Actual behavior

Unable to resolve type for all generics defined in the JSDOC

🙂 Expected behavior

All generics should resolve to actual types.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions