Microsoft/TypeScript

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

Open

#47,425 创建于 2022年1月13日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: JSDocHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

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.

贡献者指南