Skip to content

TS2302 when using two generics with the same name in JSDoc, but not in TypeScript.Β #47425

@jespertheend

Description

@jespertheend

Bug Report

πŸ”Ž Search Terms

ts2302 jsdoc

πŸ•— Version & Regression Information

  • This changed between versions 4.4.4 and 4.5.4

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

/**
 * @template T1
 * @typedef {T1} TakesT1
 */

/**
 * @template T1
 * @template T2
 */
class Foo {
    /**
     * @template T1
     * @template {TakesT1<T1>} T2
     *                    ^^--- Static members cannot reference
     *                          class type parameters.(2302)
     * @param {T1} t1
     * @param {T2} t2
     */
    static bar(t1, t2) {

    }
}

πŸ™ Actual behavior

"Static members cannot reference class type parameters." This is wrong because the equivalent typescript for this situation does not give an error: playground.

πŸ™‚ Expected behavior

No ts2302 error, TakesT1<T1> should use the T1 generic from the static bar() method, rather than from the Foo class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions